Пример #1
0
 public void Add(string assetFullName, AssetInfo asset)
 {
     Init();
     NameList.Add(assetFullName);
     InfoList.Add(asset);
     EditorUtility.SetDirty(this);
 }
Пример #2
0
        public bool AddName(string word)
        {
            if (string.IsNullOrEmpty(word) || _names.Contains(word))
            {
                return(false);
            }

            _names.Add(word);
            _namesListUppercase.Add(word.ToUpperInvariant());
            if (_languageName.StartsWith("en_", StringComparison.Ordinal) && !word.EndsWith('s'))
            {
                _names.Add(word + "s");
                _namesListUppercase.Add(word.ToUpperInvariant() + "S");
            }
            if (!word.EndsWith('s'))
            {
                _namesListWithApostrophe.Add(word + "'s");
                _namesListUppercase.Add(word.ToUpperInvariant() + "'S");
            }
            if (!word.EndsWith('\''))
            {
                _namesListWithApostrophe.Add(word + "'");
            }

            _wordsWithDashesOrPeriods.Add(word);

            var namesList = new NameList(Configuration.DictionariesDirectory, _languageName, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl);

            namesList.Add(word);
            return(true);
        }
Пример #3
0
        //Constructor
        //Init' property values

        public EntryObject()
        {
            EntryID = -1;
            NameList.Add("_null");
            TypeList.Add("_null");
            WhereList.Add("_null");
            ExtraList.Add("_null");
        }
Пример #4
0
        public void NamesListIsInNameMultiWordList()
        {
            // Arrange
            var namesList = new NameList(Directory.GetCurrentDirectory(), "ru", false, null);

            // Act
            namesList.Add("Charlie Parker123");
            var exists = namesList.IsInNamesMultiWordList("This is Charlie Parker123!", "Charlie Parker123");

            // Assert
            Assert.IsTrue(exists);
        }
Пример #5
0
        public void NamesListAddMultiWord()
        {
            // Arrange
            var namesList = new NameList(Directory.GetCurrentDirectory(), "da", false, null);

            // Act
            namesList.Add("Charlie Parker123");
            var exists = namesList.GetMultiNames().Contains("Charlie Parker123");

            // Assert
            Assert.IsTrue(exists);
        }
Пример #6
0
        public void NamesListAddWord()
        {
            // Arrange
            var namesList = new NameList(Directory.GetCurrentDirectory(), "sv", false, null);

            // Act
            namesList.Add("Jones123");
            var exists = namesList.GetNames().Contains("Jones123");

            // Assert
            Assert.IsTrue(exists);
        }
Пример #7
0
        public void NamesListRemove()
        {
            // Arrange
            var namesList = new NameList(Directory.GetCurrentDirectory(), "de", false, null);

            namesList.Add("Jones123");

            // Act
            namesList.Remove("Jones123");

            // Assert
            Assert.IsFalse(namesList.GetNames().Contains("Jones123"));
        }
Пример #8
0
        public void NamesListAddWordReload()
        {
            // Arrange
            var namesList = new NameList(Directory.GetCurrentDirectory(), "it", false, null);

            namesList.Add("Jones123");

            // Act
            namesList = new NameList(Directory.GetCurrentDirectory(), "it", false, null);

            // Assert
            Assert.IsTrue(namesList.GetNames().Contains("Jones123"));
        }
Пример #9
0
        /// <summary></summary>
        /// <param name="addToNameList"></param>
        /// <returns></returns>
        public virtual string GetNameImportedArtUidsElement(bool addToNameList)
        {
            var i = Index;

            var result = string.Format("ImportedArtUids[{0}].Element", i);

            if (addToNameList)
            {
                NameList.Add(result);
            }

            return(result);
        }
Пример #10
0
        /// <summary></summary>
        /// <param name="addToNameList"></param>
        /// <returns></returns>
        public virtual string GetNameNBTLElement(bool addToNameList)
        {
            var i = Index;

            var result = string.Format("NBTL[{0}].Element", i);

            if (addToNameList)
            {
                NameList.Add(result);
            }

            return(result);
        }
Пример #11
0
        public void NameListTest()
        {
            var textList = new NameList();

            Assert.AreEqual(0, textList.Count);
            var i = textList.Add("Sample");

            Assert.AreEqual(0, i);
            Assert.AreEqual(0, textList.IndexOf("Sample"));
            Assert.AreEqual(0, textList.IndexOf("SAMPLE"));
            Assert.AreEqual(-1, textList.IndexOf("Junk"));
            Assert.AreEqual(1, textList.Count);
        }
Пример #12
0
 public void AddName(object sender, RoutedEventArgs e)
 {
     try
     {
         PropertiesList newListItem = new PropertiesList();
         newListItem.PropID = EditingProperty.ID;
         newListItem.Value  = "";
         NameList.Add(newListItem);
         ListBoxNames.Items.Refresh();
         int ind = ListBoxNames.Items.Count - 1;
         ListBoxNames.SelectedIndex = ind;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка");
     }
 }
Пример #13
0
        /// <summary></summary>
        /// <param name="addToNameList"></param>
        /// <returns></returns>
        public virtual string GetNameDTTLElement(bool addToNameList)
        {
            string result = string.Empty;

            if (Globals.IsRulesetVersion(5, 25))
            {
                var i = Index;

                result = string.Format("DTTL[{0}].Element", i);

                if (addToNameList)
                {
                    NameList.Add(result);
                }
            }

            return(result);
        }
Пример #14
0
        //private PropValueInfo EditingPropValueInfo;

        public void AddName(object sender, RoutedEventArgs e)
        {
            try
            {
                ListsValue newListItem = new ListsValue();
                newListItem.ListID = ListID;
                newListItem.TaskID = TaskID;
                newListItem.Val    = "";
                NameList.Add(newListItem);
                ListBoxNames.Items.Refresh();
                int ind = ListBoxNames.Items.Count - 1;
                ListBoxNames.SelectedIndex = ind;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка");
            }
        }
Пример #15
0
        public BMDEditorVM(GameFile objbmd)
        {
            FromCommand = new RelayCommand(Replace);
            TestCommand = new RelayCommand(Test);

            if (objbmd.GameData is BMD bmd)
            {
                EncodingEW = new EventWrapperINPC(Static.EncodingManager, this);

                int sourceInd = Static.EncodingManager.GetPersonaEncodingIndex(ApplicationSettings.AppSetting.Default.BMDFontDefault);
                if (sourceInd >= 0)
                {
                    sourceFont = sourceInd;
                }
                else
                {
                    sourceFont = 0;
                }

                sourceInd = Static.EncodingManager.GetPersonaEncodingIndex(ApplicationSettings.AppSetting.Default.BMDFontDestDefault);
                if (sourceInd >= 0)
                {
                    destFont = sourceInd;
                }
                else
                {
                    destFont = 0;
                }


                foreach (var a in bmd.Name)
                {
                    NameList.Add(new BMDNameVM(a, sourceFont));
                }
                foreach (var a in bmd.Msg)
                {
                    MsgList.Add(new BMDMsgVM(a, sourceFont));
                }



                Name = objbmd.Name;
            }
        }
Пример #16
0
        /// <summary>
        /// Generates a list of distinct names based on the available <see cref="MarkovData"/>. Does not use names that
        /// have already been generated during the lifetime of the current Name Source. Call <see cref="ClearNameList"/>
        /// to clear the list of previously used names.
        /// </summary>
        /// <returns>A list of names no longer than the set <see cref="ListSize"/></returns>
        public List <string> GenerateWordList()
        {
            List <string> names = new List <string>();

            int i = 0;

            while (i < ListSize)
            {
                var nextName = GenerateWord();
                if (!NameList.Contains(nextName))
                {
                    NameList.Add(nextName);
                    names.Add(nextName);
                    i++;
                }
            }

            return(names);
        }
Пример #17
0
        /// <summary>
        /// Build standard sql and get field list and sort list
        /// </summary>
        string buildSql(int[] acctTypes, out NameList fields, out NameList sort)
        {
            sort = new NameList(n => n.SortName, _x2, _x1);
            sort.Add("DocumentDate");
            fields = new NameList(n => n.FieldName, _x1, _x2);
            fields.AddRange(sort);
            NameList allFields = new NameList(fields, _y.GetNames().Select(n => n.FieldName));

            // Build standard sql to use if there are no opening balances to consider
            return("SELECT " + allFields + @"
FROM Journal
LEFT JOIN Account ON Account.idAccount = Journal.AccountId
LEFT JOIN AccountType ON AccountType.idAccountType = Account.AccountTypeId
LEFT JOIN NameAddress ON NameAddress.idNameAddress = Journal.NameAddressId
LEFT JOIN Line ON Line.idLine = Journal.idJournal
LEFT JOIN Document ON Document.idDocument = Journal.DocumentId
LEFT JOIN DocumentType ON DocumentType.idDocumentType = Document.DocumentTypeId"
                   + getFilterWhere("AccountTypeId " + Database.In(acctTypes),
                                    _dates.Active ? null : "DocumentDate < " + Database.Quote(Utils.Today.AddDays(1))));
        }
        public void AddFriend(JournalFriends next)
        {
            if (StatusList == null)     // if first time we added, move to status list format
            {
                StatusList = new List <FriendStatus>()
                {
                    StatusEnum
                };
                NameList = new List <string>()
                {
                    Name
                };
                Status = Name = string.Empty;
            }

            StatusList.Add(next.StatusEnum);
            NameList.Add(next.Name);

            OfflineCount = next.StatusEnum == FriendStatus.Offline ? 1 : 0;
            OnlineCount  = next.StatusEnum == FriendStatus.Online ? 1 : 0;
        }
Пример #19
0
        private void ButtonAddNamesClick(object sender, EventArgs e)
        {
            var languageIndex = comboBoxWordListLanguage.SelectedIndex;
            if (languageIndex < 0)
            {
                return;
            }

            var language = GetCurrentWordListLanguage();
            var text = textBoxNameEtc.Text.RemoveControlCharacters().Trim();
            if (!string.IsNullOrEmpty(language) && text.Length > 1 && !_wordListNames.Contains(text))
            {
                var nameList = new NameList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl);
                nameList.Add(text);
                LoadNames(language, true);
                labelStatus.Text = string.Format(LanguageSettings.Current.Settings.WordAddedX, text);
                textBoxNameEtc.Text = string.Empty;
                textBoxNameEtc.Focus();
                for (int i = 0; i < listViewNames.Items.Count; i++)
                {
                    if (listViewNames.Items[i].ToString() == text)
                    {
                        listViewNames.Items[i].Selected = true;
                        listViewNames.Items[i].Focused = true;
                        var top = i - 5;
                        if (top < 0)
                        {
                            top = 0;
                        }

                        listViewNames.EnsureVisible(top);
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show(LanguageSettings.Current.Settings.WordAlreadyExists);
            }
        }
Пример #20
0
        public BMDEditorVM(ObjectFile objbmd)
        {
            if (objbmd.Object is BMD bmd)
            {
                EncodingEW = new EventWrapper(Static.EncodingManager, this);

                int sourceInd = Static.EncodingManager.GetPersonaEncodingIndex(Settings.AppSetting.Default.BMDFontDefault);
                if (sourceInd >= 0)
                {
                    sourceFont = sourceInd;
                }
                else
                {
                    sourceFont = 0;
                }

                sourceInd = Static.EncodingManager.GetPersonaEncodingIndex(Settings.AppSetting.Default.BMDFontDestDefault);
                if (sourceInd >= 0)
                {
                    destFont = sourceInd;
                }
                else
                {
                    destFont = 0;
                }


                foreach (var a in bmd.Name)
                {
                    NameList.Add(new BMDNameVM(a, sourceFont));
                }
                foreach (var a in bmd.Msg)
                {
                    MsgList.Add(new BMDMsgVM(a, sourceFont));
                }

                Name = objbmd.Name;
            }
        }
Пример #21
0
        public void AddFriend(JournalFriends next)
        {
            if (StatusList == null)     // if first time we added, move to status list format
            {
                StatusList = new List <string>()
                {
                    Status
                };
                NameList = new List <string>()
                {
                    Name
                };
                Status = Name = string.Empty;
            }

            string stat = next.Status;

            StatusList.Add(stat);
            NameList.Add(next.Name);

            OfflineCount += stat.Equals("offline", System.StringComparison.InvariantCultureIgnoreCase) ? 1 : 0;
            OnlineCount  += stat.Equals("online", System.StringComparison.InvariantCultureIgnoreCase) ? 1 : 0;
        }
Пример #22
0
        public void ShowChosenDate()
        {
            if (SelectedDate != null)
            {
                NameList.Clear();

                Pinsa pricePinsa = new Pinsa()
                {
                    Name = "Total Price: " + SelectedDate.Price.ToString()
                };                                                                                         //Total Price is made like a Pinsa so it can be shown on the list together with the other "Real" pinsas
                hvm = new HistoryViewModel(pricePinsa);
                NameList.Add(hvm);

                foreach (Pinsa pinsa in or.Order)
                {
                    if (SelectedDate.Date == pinsa.Date)
                    {
                        hvm = new HistoryViewModel(pinsa);
                        NameList.Add(hvm);
                    }
                }
            }
        }
Пример #23
0
        private void ButtonOkClick(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBoxAddName.Text) || comboBoxDictionaries.SelectedIndex < 0)
            {
                return;
            }

            NewName = textBoxAddName.Text.RemoveControlCharacters().Trim();
            string languageName;

            try
            {
                languageName = comboBoxDictionaries.Items[comboBoxDictionaries.SelectedIndex].ToString();
                languageName = languageName.Substring(languageName.LastIndexOf("[", StringComparison.Ordinal)).TrimStart('[').TrimEnd(']');
            }
            catch
            {
                languageName = "en";
            }

            var nameList = new NameList(Configuration.DictionariesDirectory, languageName, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl);

            DialogResult = nameList.Add(textBoxAddName.Text) ? DialogResult.OK : DialogResult.Cancel;
        }
Пример #24
0
        /// <summary>
        /// Initialize the <see cref="Package"/> by reading from the given filename.
        /// </summary>
        /// <param name="state">The <see cref="State"/> this <see cref="Package"/> is to exist within.</param>
        /// <param name="fileName">The name of the file to open that contains the <see cref="Package"/>.</param>
        /// <param name="reader">The <see cref="BinaryReader"/> to read from.</param>
        public Package(State state, string fileName, BinaryReader reader)
        {
            if (state == null)
                throw new ArgumentNullException("state");
            if (reader == null)
                throw new ArgumentNullException("reader");

            if (reader.ReadInt32() != Magic)
                throw new Exception("Unreal package magic test failed.");
            Reader = reader;

            FileName = fileName;
            Export = new Unreal.Export(this, -1);
            Export.Name = Path.GetFileNameWithoutExtension(fileName);
            Export.LoadedObject = this;

            StateValue = state;
            FileVersion = reader.ReadUInt16();
            LicenseMode = reader.ReadUInt16();
            Flags = (PackageFlag)reader.ReadUInt32();
            var nameCount = reader.ReadInt32();
            var nameOffset = reader.ReadUInt32();
            var exportCount = reader.ReadInt32();
            var exportOffset = reader.ReadUInt32();
            var importCount = reader.ReadInt32();
            var importOffset = reader.ReadUInt32();
            if (FileVersion >= 68)
                Guid = new Guid(reader.ReadBytes(16));

            Imports = new ImportList(importCount);
            for (var index = 0; index < importCount; index++)
                Imports.Add(new Import(this, index));

            Exports = new ExportList(exportCount);
            for (var index = 0; index < exportCount; index++)
                Exports.Add(new Export(this, index));

            Names = new NameList(nameCount);
            reader.BaseStream.Position = nameOffset;
            for (var index = 0; index < nameCount; index++)
                Names.Add(new Name(this, reader));

            reader.BaseStream.Position = exportOffset;
            for (var index = 0; index < exportCount; index++)
                Exports[index].Load(reader);

            reader.BaseStream.Position = importOffset;
            for (var index = 0; index < importCount; index++)
                Imports[index].Load(reader);

            FilteredExports = new ExportList(exportCount);
            foreach (var export in Exports) {
                /*if(export.ObjectClassReference != null && export.ObjectClassReference.Name.EndsWith("Property")) {
                    if(((((Alexandria.Engines.Unreal.Core.Property)export.Object).PropertyFlags) & Alexandria.Engines.Unreal.Core.PropertyFlag.Test) != 0)
                        FilteredExports.Add(export);
                }*/
                if (export.ObjectClassReference == null || !export.ObjectClassReference.Name.EndsWith("Property"))
                    FilteredExports.Add(export);
            }

            Game = DetermineGame(FileVersion, LicenseMode, IsEncrypted);
        }
Пример #25
0
    /**/
    /// <summary>
    /// 是否动态改变颜色
    /// </summary>
    public bool IsChangeColor = false;
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        zedGraphControl.Width        = ZGWidth;
        zedGraphControl.Height       = ZGHeight;
        zedGraphControl.RenderGraph += new ZedGraph.Web.ZedGraphWebControlEventHandler(zedGraphControl_RenderGraph);

        //保存位置(ZedGraph/Images目录可以自定义)
        FilePath = "~/Admin/Controls/ZedGraph/";
        zedGraphControl.RenderedImagePath = FilePath;
    }

    private void InitDefaultColors()
    {
        //以下为颜色样例
        //defaultColors.Add(Color.Red);
        //defaultColors.Add(Color.Green);
        //defaultColors.Add(Color.Blue);
        //defaultColors.Add(Color.Yellow);
        //defaultColors.Add(Color.YellowGreen);
        //defaultColors.Add(Color.Brown);
        //defaultColors.Add(Color.Aqua);
        //defaultColors.Add(Color.Cyan);
        //defaultColors.Add(Color.DarkSeaGreen);
        //defaultColors.Add(Color.Indigo);

        if (IsChangeColor)
        {
            defaultColors.Add(Color.FromArgb(255, 158, 158));    //红色
            defaultColors.Add(Color.FromArgb(167, 233, 145));    //绿色
            defaultColors.Add(Color.FromArgb(145, 233, 255));    //蓝色
            defaultColors.Add(Color.FromArgb(255, 255, 145));    //黄色
            defaultColors.Add(Color.FromArgb(211, 233, 145));    //黄绿
            defaultColors.Add(Color.FromArgb(255, 145, 255));    //紫色
            defaultColors.Add(Color.FromArgb(0, 153, 255));
            defaultColors.Add(Color.FromArgb(255, 204, 0));
            defaultColors.Add(Color.FromArgb(76, 183, 255));  //
            defaultColors.Add(Color.FromArgb(255, 214, 51));
            defaultColors.Add(Color.FromArgb(127, 204, 255)); //
            defaultColors.Add(Color.FromArgb(255, 224, 102));
            defaultColors.Add(Color.FromArgb(166, 219, 255)); //
            defaultColors.Add(Color.FromArgb(255, 235, 153));
            defaultColors.Add(Color.FromArgb(204, 235, 255)); //
            defaultColors.Add(Color.FromArgb(255, 245, 204));
        }
        else
        {
            defaultColors.Add(Color.FromArgb(0, 153, 255));   //
            defaultColors.Add(Color.FromArgb(255, 204, 0));
            defaultColors.Add(Color.FromArgb(76, 183, 255));  //
            defaultColors.Add(Color.FromArgb(255, 214, 51));
            defaultColors.Add(Color.FromArgb(127, 204, 255)); //
            defaultColors.Add(Color.FromArgb(255, 224, 102));
            defaultColors.Add(Color.FromArgb(166, 219, 255)); //
            defaultColors.Add(Color.FromArgb(255, 235, 153));
            defaultColors.Add(Color.FromArgb(204, 235, 255)); //
            defaultColors.Add(Color.FromArgb(255, 245, 204));
        }
    }

    /**/
    /// <summary>
    /// 如果属性为空则初始化属性数据
    /// </summary>
    private void InitProperty()
    {
        InitDefaultColors();
        if (string.IsNullOrEmpty(Title))
        {
            Title = string.Empty;
        }
        if (string.IsNullOrEmpty(XAxisTitle))
        {
            XAxisTitle = "横轴";
        }
        if (string.IsNullOrEmpty(YAxisTitle))
        {
            YAxisTitle = "纵轴";
        }
        if (Type == AnalyticsType.Pie)
        {
            Count = ScaleData.Count;
        }
        else
        {
            Count = DataSource.Count;
        }
        if (Colors.Count == 0 || Colors.Count != Count)
        {
            if (IsChangeColor)
            {
                for (int i = 0; i < 16; i++)
                {
                    Colors.Add(defaultColors[i]);
                }
            }
            else
            {
                for (int i = 0; i < 10; i++)
                {
                    Colors.Add(defaultColors[i]);
                }
            }
        }
        if (NameList.Count == 0)
        {
            if (Type == AnalyticsType.Bar || Type == AnalyticsType.Line)
            {
                for (int i = 0; i < DataSource[0].Count; i++)
                {
                    NameList.Add((i + 1).ToString());
                }
            }
            else
            {
                for (int i = 0; i < Count; i++)
                {
                    NameList.Add((i + 1).ToString());
                }
            }
        }
        if (LabelList.Count == 0)
        {
            if (Count > 5)
            {
                int k = 1;
                for (int i = 0; i < Count; i++)
                {
                    LabelList.Add("名称 " + k.ToString());

                    if (i % 2 != 0)
                    {
                        k++;
                    }
                }
            }
            else
            {
                for (int i = 0; i < Count; i++)
                {
                    LabelList.Add("名称 " + (i + 1).ToString());
                }
            }
        }
    }
Пример #26
0
        private void ButtonOkClick(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBoxAddName.Text))
            {
                return;
            }

            NewName = textBoxAddName.Text.RemoveControlCharacters().Trim();
            string languageName = null;

            _language = Configuration.Settings.Language.Main;

            if (!string.IsNullOrEmpty(Configuration.Settings.General.SpellCheckLanguage))
            {
                languageName = Configuration.Settings.General.SpellCheckLanguage;
            }
            else
            {
                List <string> list = Utilities.GetDictionaryLanguages();
                if (list.Count > 0)
                {
                    string name  = list[0];
                    int    start = name.LastIndexOf('[');
                    int    end   = name.LastIndexOf(']');
                    if (start > 0 && end > start)
                    {
                        start++;
                        name         = name.Substring(start, end - start);
                        languageName = name;
                    }
                    else
                    {
                        MessageBox.Show(string.Format(_language.InvalidLanguageNameX, name));
                        return;
                    }
                }
            }

            languageName = LanguageAutoDetect.AutoDetectLanguageName(languageName, _subtitle);
            if (comboBoxDictionaries.Items.Count > 0)
            {
                string name  = comboBoxDictionaries.SelectedItem.ToString();
                int    start = name.LastIndexOf('[');
                int    end   = name.LastIndexOf(']');
                if (start >= 0 && end > start)
                {
                    start++;
                    name         = name.Substring(start, end - start);
                    languageName = name;
                }
            }

            if (string.IsNullOrEmpty(languageName))
            {
                languageName = "en_US";
            }

            var nameList = new NameList(Configuration.DictionariesDirectory, languageName, Configuration.Settings.WordLists.UseOnlineNames, Configuration.Settings.WordLists.NamesUrl);

            if (nameList.Add(textBoxAddName.Text))
            {
                DialogResult = DialogResult.OK;
            }
            else
            {
                DialogResult = DialogResult.Cancel;
            }
        }
Пример #27
0
 public void NewBrench(string name, string indexingTreeID)
 {
     NameList.Add(name);
     IndexingTreeIDList.Add(indexingTreeID);
 }
Пример #28
0
            private void ReadMessage(string message)
            {
                bool doubleLogin = false;

                BatProtocol deSerializedMessage = JsonConvert.DeserializeObject <BatProtocol>(message);

                //Testar om message är av typen login
                if (deSerializedMessage.Type == "Login")
                {
                    Console.WriteLine("logging in...");

                    //Kolla om redan inloggad
                    if (NameList != null && NameList.Contains(deSerializedMessage.UserName))
                    {
                        Console.WriteLine(deSerializedMessage.UserName + "Redan inloggad");
                        //Skickar felmessage i retur
                        doubleLogin = true;
                        NetworkStream n  = tcpclient.GetStream();
                        BatProtocol   ok = new BatProtocol {
                            Type = "DoubleLogin"
                        };

                        new BinaryWriter(n).Write(JsonConvert.SerializeObject(ok));
                    }

                    //kollar om username finns i databasen
                    else if (Context.BatUsers.ToList()
                             .Exists(u => u.Name == deSerializedMessage.UserName))
                    {
                        if (NameList == null)
                        {
                            NameList = new List <string> {
                                deSerializedMessage.UserName
                            };
                        }
                        else
                        {
                            NameList.Add(deSerializedMessage.UserName);
                        }

                        Console.WriteLine(deSerializedMessage.UserName + " User Exists");
                    }
                    else if (!(Context.BatUsers.ToList().Exists(s => s.Name.Equals(deSerializedMessage.UserName))))
                    {
                        Console.WriteLine(deSerializedMessage.UserName + " does not exists. Creating a new user...");
                        try
                        {
                            BatUsers newUser = new BatUsers {
                                Name = deSerializedMessage.UserName, Password = deSerializedMessage.Password
                            };
                            Context.BatUsers.Add(newUser);
                            Context.SaveChanges();
                            Console.WriteLine("Creation succesful!");

                            if (NameList == null)
                            {
                                NameList = new List <string> {
                                    deSerializedMessage.UserName
                                };
                            }
                            else
                            {
                                NameList.Add(deSerializedMessage.UserName);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    //Kollar om lösenord matchar med det som är lagt in i databasen under samma login.
                    if (!doubleLogin && Context.BatUsers.ToList()
                        .Find(u => u.Name == deSerializedMessage.UserName)
                        .Password == deSerializedMessage.Password)
                    {
                        Console.WriteLine("Login Successful");
                        //Skickar message i retur
                        NetworkStream n  = tcpclient.GetStream();
                        BatProtocol   ok = new BatProtocol {
                            Type = "Ok"
                        };
                        if (NameList != null)
                        {
                            ok.Userlist = NameList;
                        }



                        new BinaryWriter(n).Write(JsonConvert.SerializeObject(ok));
                    }
                }

                else if (deSerializedMessage.Type == "PM")
                {
                    Console.WriteLine(deSerializedMessage.UserName + " PM: " + deSerializedMessage.Message);

                    NetworkStream n = tcpclient.GetStream();

                    deSerializedMessage.Type = "SM";
                    if (NameList != null)
                    {
                        deSerializedMessage.Userlist = NameList;
                    }


                    //new BinaryWriter(n).Write(JsonConvert.SerializeObject(deSerializedMessage));
                    myServer.Broadcast(this, JsonConvert.SerializeObject(deSerializedMessage));
                }

                else
                {
                    Console.WriteLine("Unhandled message Type");
                }
            }