コード例 #1
0
ファイル: MainForm.cs プロジェクト: Hazaaa/TextCorrect
        public void ReplaceWordInText(string word, string replaceWith, bool firstOccurrence)
        {
            if (word == "" || replaceWith == "")
            {
                return;
            }

            if (firstOccurrence)
            {
                int indexWord = EnteredText.IndexOf(word);

                if (indexWord != -1)
                {
                    var replacedText = EnteredText.Remove(indexWord, word.Length).Insert(indexWord, replaceWith);
                    EnteredText = replacedText;
                }
            }
            else
            {
                var replacedText = EnteredText.Replace(word, replaceWith);
                EnteredText = replacedText;
            }

            txbReplaceWith.Text   = "";
            txbWordToReplace.Text = "";
        }
コード例 #2
0
 public void PickSelection()
 {
     if (_selectedIndex < _chars.Count())
     {
         if (EnteredText.Length < MaxLength)
         {
             EnteredText += _chars[_selectedIndex];
         }
     }
     //Backspace
     if (_selectedIndex == _chars.Count())
     {
         if (EnteredText.Length > 0)
         {
             EnteredText = EnteredText.Substring(0, EnteredText.Length - 1);
         }
     }
     //Cancel
     if (_selectedIndex == _chars.Count() + 1)
     {
         if (EntryCancelled != null)
         {
             EntryCancelled(this, null);
         }
     }
     //Decide
     if (_selectedIndex == _chars.Count() + 2)
     {
         if (EntryComplete != null)
         {
             EntryComplete(this, null);
         }
     }
 }
コード例 #3
0
 protected override IEnumerable <IRecord> GetSearchResults()
 {
     if (LookupService == null)
     {
         throw new NullReferenceException(string.Format("Error searching field {0}. {1} is null", FieldName, "LookupService"));
     }
     if (UsePicklist)
     {
         return(FormService.GetLookupPicklist(FieldName, RecordEntryViewModel.GetRecordType(),
                                              RecordEntryViewModel.ParentFormReference, RecordEntryViewModel.GetRecord(), LookupService, RecordTypeToLookup));
     }
     else
     {
         var primaryField = LookupService.GetPrimaryField(RecordTypeToLookup);
         var conditions   = FormService.GetLookupConditions(FieldName, RecordEntryViewModel.GetRecordType(),
                                                            RecordEntryViewModel.ParentFormReference, RecordEntryViewModel.GetRecord());
         if (!EnteredText.IsNullOrWhiteSpace())
         {
             conditions =
                 conditions.Union(new[] { new Condition(primaryField, ConditionType.BeginsWith, EnteredText) });
         }
         return(LookupService.GetFirstX(RecordTypeToLookup, UsePicklist ? -1 : MaxRecordsForLookup, null,
                                        conditions, new[] { new SortExpression(primaryField, SortType.Ascending) }));
     }
 }
コード例 #4
0
        protected override IEnumerable <IRecord> GetSearchResults()
        {
            var records = LookupService.GetLinkedRecords(null, null, GetSettingLookupAttribute().PropertyName, null);

            if (!UsePicklist && !EnteredText.IsNullOrWhiteSpace())
            {
                records = records.Where(r => r.GetStringField("ToString") != null && r.GetStringField("ToString").ToLower().StartsWith(EnteredText.ToLower()));
            }
            return(records);
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: Hazaaa/TextCorrect
        private void btnLoadTextFormFile_Click(object sender, EventArgs e)
        {
            if (ofdLoadFile.ShowDialog() == DialogResult.OK)
            {
                string path = ofdLoadFile.FileName;

                using (StreamReader sr = new StreamReader(path))
                {
                    if (EnteredText != "\r\n")
                    {
                        if (System.Windows.Forms.MessageBox.Show("You have unsaved text. Are you sure you want to overwrite it?", "Overwrite", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            EnteredText = sr.ReadToEnd();

                            if (SelectedLanguage != Language.English)
                            {
                                if (EnteredText.ToUpper().Contains("И"))
                                {
                                    SelectedLanguage = Language.Serbian_cyrillic;
                                }
                                else
                                {
                                    SelectedLanguage = Language.Serbian_latin;
                                }
                            }
                            SetSpellCheckDictionary();
                        }
                    }
                    else
                    {
                        EnteredText = sr.ReadToEnd();

                        if (SelectedLanguage != Language.English)
                        {
                            if (EnteredText.ToUpper().Contains("И"))
                            {
                                SelectedLanguage = Language.Serbian_cyrillic;
                            }
                            else
                            {
                                SelectedLanguage = Language.Serbian_latin;
                            }
                        }
                        SetSpellCheckDictionary();
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Отправляет сообщение в беседу.
        /// </summary>
        private async Task SendMessage()
        {
            var text = EnteredText.Trim();

            EnteredText = String.Empty;
            var msg = new VKMessage
            {
                Body        = text,
                Date        = DateTime.Now,
                ChatID      = IsChat ? ChatID : 0,
                UserID      = ServiceHelper.SettingsService.AccessToken.UserID,
                Type        = VKMessageType.Sent,
                SentType    = VKSentMessageType.Sending,
                Attachments = Attachments.ToList()
            };

            Messages.Insert(0, msg);
            Messages.NewSentMessages.Add(msg);

            var param = new Dictionary <string, string>();

            param["message"] = text;

            if (IsChat)
            {
                param["chat_id"] = ChatID.ToString();
            }
            else
            {
                param["user_id"] = UserID.ToString();
            }

            var request  = new UniversalVKRequest <ulong>(VKMethodsConstants.MessageSend, param);
            var response = await request.ExecuteAsync();

            if (response.Error.ErrorType == VKErrors.None)
            {
                msg.ID       = response.Response;
                msg.SentType = VKSentMessageType.Unread;
            }
            else
            {
                msg.SentType = VKSentMessageType.Error;
            }
        }