Ejemplo n.º 1
0
        public FormMain()
        {
            InitializeComponent();

            //messages = new List<Message>();
            //mobile.SmsProvider.SMSMessageReceived += OnSmsReceived;

            formats    = new Formats();
            formatter += formats.FormatNone;

            myTimerReceive.Tick    += new EventHandler(TimerEventReceiveProcessor);
            myTimerReceive.Interval = 1000;
            myTimerReceive.Start();

            myTimerSend.Tick    += new EventHandler(TimerEventSendProcessor);
            myTimerSend.Interval = 2000;
            myTimerSend.Start();

            mobile.Store.MessageAdded   += UpdateListViewMsg;
            mobile.Store.MessageRemoved += UpdateListViewMsg;

            dateTimePicker1.Value = DateTime.Now.AddDays(-1);
            dateTimePicker2.Value = DateTime.Now.AddDays(+1);

            checkedListBox1.SetItemChecked(2, true);
        }
Ejemplo n.º 2
0
        public FormatDelegate GetFormatter(string selectedFormat)
        {
            switch (selectedFormat)
            {
            case "Start with DateTime":
                FormatterDel = SMSFormat.FormatTimeStarts;
                break;

            case "End with DateTime":
                FormatterDel = SMSFormat.FormatTimeEnds;
                break;

            case "Upper case":
                FormatterDel = SMSFormat.FormatUpperCase;
                break;

            case "Lower case":
                FormatterDel = SMSFormat.FormatLowerCase;
                break;

            case "Custom":
                FormatterDel = SMSFormat.FormatCustom;
                break;

            default:
                FormatterDel = SMSFormat.FormatDefault;
                break;
            }
            return(FormatterDel);
        }
Ejemplo n.º 3
0
        private void comboBoxSelectFormat_SelectedIndexChanged(object sender, EventArgs e)
        {
            Delegate.RemoveAll(formatter, formatter);
            switch (comboBoxSelectFormat.SelectedIndex)
            {
            case 0:
                formatter += formats.FormatNone;
                break;

            case 1:
                formatter += formats.FormatWithTime;
                break;

            case 2:
                formatter += formats.FormatWithTimeEnd;
                break;

            case 3:
                formatter += formats.FormatCustom;
                break;

            case 4:
                formatter += formats.FormatLowerCase;
                break;

            case 5:
                formatter += formats.FormatUpperCase;
                break;

            default:
                formatter += formats.FormatNone;
                break;
            }
        }
Ejemplo n.º 4
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var formatChoise = (SMSFormat.FormatOption)comboBox1.SelectedIndex;

            switch (formatChoise)
            {
            case SMSFormat.FormatOption.None:
                Formatter = SMSFormat.FormatNone;
                break;

            case SMSFormat.FormatOption.StartWithDateTime:
                Formatter = SMSFormat.FormatStartWithTime;
                break;

            case SMSFormat.FormatOption.EndWithDateTime:
                Formatter = SMSFormat.FormatEndWithTime;
                break;

            case SMSFormat.FormatOption.Custom:
                Formatter = SMSFormat.FormatCustom;
                break;

            case SMSFormat.FormatOption.LowerCase:
                Formatter = SMSFormat.FormatLowerCase;
                break;

            case SMSFormat.FormatOption.UpperCase:
                Formatter = SMSFormat.FormatUpperCase;
                break;

            default:
                MessageBox.Show("Wrong format message is chosen.");
                break;
            }
        }
Ejemplo n.º 5
0
        private void MessageFormatCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            var item = (ItemMessageFormatCB)MessageFormatCB.SelectedItem;

            Formatter = item.Formatter;
            RefreshMessagesView();
        }
Ejemplo n.º 6
0
        public void SetFormatting(int formatNumber)
        {
            if (formatNumber >= 0 && formatNumber <= 5)
            {
                switch (formatNumber)
                {
                case 0:
                    Formatter = null;
                    break;

                case 1:
                    Formatter = FormatWithDateStart;
                    break;

                case 2:
                    Formatter = FormatWithDateEnd;
                    break;

                case 3:
                    Formatter = FormatWithLowerCase;
                    break;

                case 4:
                    Formatter = FormatWithUpperCase;
                    break;

                case 5:
                    Formatter = FormatWithTime;
                    break;
                }
            }
        }
Ejemplo n.º 7
0
        public void FormatDelegate_Works_WithSmartFormat(string format, string expected)
        {
            var smart          = Smart.CreateDefaultSmartFormat();
            var formatDelegate = new FormatDelegate((text) => HtmlActionLink(text ?? "null", "SomePage"));

            Assert.That(smart.Format(format, formatDelegate), Is.EqualTo(expected));
        }
        public static bool format(char letter, String fileSystemName, UInt32 allocationSize, String label)
        {
            bool result = false;

            string helperDLLName = "misterhelper.dll";

            EmbeddedDll.ExtractEmbeddedDlls(helperDLLName);
            IntPtr hDll = EmbeddedDll.LoadDll(helperDLLName);

            if (hDll != IntPtr.Zero)
            {
                IntPtr         pAddrFormatFunction = GetProcAddress(hDll, "Format");
                FormatDelegate formatDelegate      = (FormatDelegate)Marshal.GetDelegateForFunctionPointer(pAddrFormatFunction, typeof(FormatDelegate));
                result = formatDelegate(letter.ToString(), fileSystemName, allocationSize, label);

                FreeLibrary(hDll);
            }

            /*
             * Call from direct reference
             * {
             *  Format(letter.ToString(), fileSystemName, allocationSize, label);
             * }
             */

            return(result);
        }
Ejemplo n.º 9
0
        public void ApplyFormat(int index)
        {
            switch (index)
            {
            case 0:
                Formatter = new FormatDelegate((s, t) => s);
                break;

            case 1:
                Formatter = new FormatDelegate((s, t) => $"[{t}] {s}");
                break;

            case 2:
                Formatter = new FormatDelegate((s, t) => $"{s} [{t}]");
                break;

            case 3:
                Formatter = new FormatDelegate((s, t) => $"-={s}=-");
                break;

            case 4:
                Formatter = new FormatDelegate((s, t) => s.ToLower());
                break;

            case 5:
                Formatter = new FormatDelegate((s, t) => s.ToUpper());
                break;

            default:
                Formatter = new FormatDelegate((s, t) => s);
                break;
            }
        }
Ejemplo n.º 10
0
 private void ShowMessages(List <MyMessage> myReceivedMessages, FormatDelegate currentFormat)
 {
     MessageListView.Items.Clear();
     foreach (MyMessage message in myReceivedMessages)
     {
         MessageListView.Items.Add(new ListViewItem(new[] { message.User, Format.OnSMSReceived(message, currentFormat) }));
     }
 }
Ejemplo n.º 11
0
 public PlainTextFormatter(Func <T, string> format)
 {
     _format = (instance, context) =>
     {
         context.Writer.Write(format(instance));
         return(true);
     };
 }
Ejemplo n.º 12
0
        private void FormatComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            FormatItem itm = (FormatItem)FormatComboBox.SelectedItem;

            Formatter = itm.FormatDel;
            DisplayAll(simCorp.MsgStor.MsgList);
            ChargeProgressBar.Value = simCorp.Battery.GetCurrentCharge();
        }
Ejemplo n.º 13
0
		/// <summary>
		/// Junta os elementos de uma coleção em uma string, com o delimitador especificado.
		/// </summary>
		/// <param name="en">A coleção</param>
		/// <param name="delimiter">O delimitador</param>
		/// <param name="formatDelegate">O formatador</param>
		/// <returns>Uma string com a representação string de todos os objetos, separados pelo delimitador especificado</returns>
		public static string Join(IEnumerable en, string delimiter, FormatDelegate formatDelegate)
		{
			var sb = new StringBuilder();
			foreach (object obj in en)
				sb.AppendFormat("{0}", formatDelegate(obj)).Append(delimiter);
			if (sb.Length >= delimiter.Length)
				sb.Length -= delimiter.Length;
			return sb.ToString();
		}
Ejemplo n.º 14
0
        public void FormatDelegate_WithCulture_WithSmartFormat()
        {
            var amount         = (decimal)123.456;
            var c              = new CultureInfo("fr-FR");
            var formatDelegate = new FormatDelegate((text, culture) => GetAnswer("The amount is: ", amount, c));

            Assert.That(Smart.Format("{0}", formatDelegate)
                        , Is.EqualTo($"The amount is: {amount.ToString(c)}"));
        }
Ejemplo n.º 15
0
        public PlainTextFormatter(Action <T, FormatContext> format)
        {
            _format = FormatInstance;

            bool FormatInstance(T instance, FormatContext context)
            {
                format(instance, context);
                return(true);
            }
        }
        public TabularDataResourceFormatter(Action <T, FormatContext> format)
        {
            _format = FormatInstance;

            bool FormatInstance(T instance, FormatContext context)
            {
                format(instance, context);
                return(true);
            }
        }
Ejemplo n.º 17
0
 private void formatingComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     FormatDelegate[] formatDelegates = new FormatDelegate[]
     {
         MessagesFormater.NoFormat,
         MessagesFormater.StartWithDateTimeFormat,
         MessagesFormater.UpperCaseFormat
     };
     MessagesFormater.FormaterMethod = formatDelegates[formatingComboBox.SelectedIndex];
 }
Ejemplo n.º 18
0
        public void FormatDelegate_WithCulture()
        {
            var smart  = Smart.CreateDefaultSmartFormat();
            var amount = (decimal)123.456;
            var c      = new CultureInfo("fr-FR");
            // Only works for indexed placeholders
            var formatDelegate = new FormatDelegate((text, culture) => $"{text}: {amount.ToString(c)}");

            Assert.That(smart.Format("{0:The amount is}", formatDelegate)
                        , Is.EqualTo($"The amount is: {amount.ToString(c)}"));
        }
Ejemplo n.º 19
0
        public void FormatterDel_Default()
        {
            string            message      = "message";
            SMSModuleEnhanced myModule     = new SMSModuleEnhanced();
            FormatDelegate    FormatterDel = myModule.GetFormatter("default");
            var expresult = message + "\r\n";

            var actresult = FormatterDel(message);

            Assert.AreEqual(expresult, actresult);
        }
Ejemplo n.º 20
0
        private string RaiseFormatEvent(string message)
        {
            string         str     = "";
            FormatDelegate handler = Formatter as FormatDelegate;

            if (handler != null)
            {
                str = handler(message);
            }
            return(str);
        }
Ejemplo n.º 21
0
        public JsonFormatter()
        {
            _format = FormatInstance;

            bool FormatInstance(T instance, FormatContext context)
            {
                var json = JsonSerializer.Serialize(instance, JsonFormatter.SerializerOptions);

                context.Writer.Write(json);
                return(true);
            }
        }
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     FormatDelegate[] formatDelegates = new FormatDelegate[]
     {
         Formatter.NoFormat,
         Formatter.StartWithDateTimeFormat,
         Formatter.EndWithDateTimeFormat,
         Formatter.UpperCaseFormat,
         Formatter.LowerCaseFormat
     };
     Formatter.FormatMethod = formatDelegates[formattingComboBox.SelectedIndex];
 }
Ejemplo n.º 23
0
        public void FormatterDel_StartWithDateTime()
        {
            string            message      = "message";
            SMSModuleEnhanced myModule     = new SMSModuleEnhanced();
            FormatDelegate    FormatterDel = myModule.GetFormatter("Start with DateTime");
            var expresult = DateTime.Now.ToString().Length + 2;

            var txtresult = FormatterDel(message);
            var actresult = txtresult.IndexOf("message");

            Assert.AreEqual(expresult, actresult);
        }
Ejemplo n.º 24
0
        public void FormatDelegate_Works_WithSmartFormat()
        {
            var formatDelegate = new FormatDelegate((text) => HtmlActionLink(text ?? "null", "SomePage"));

            Assert.That(Smart.Format("Please visit {0:this page} for more info.", formatDelegate)
                        , Is.EqualTo("Please visit <a href='www.example.com/SomePage'>this page</a> for more info."));

            Assert.That(Smart.Format("And {0:this other page} is cool too.", formatDelegate)
                        , Is.EqualTo("And <a href='www.example.com/SomePage'>this other page</a> is cool too."));

            Assert.That(Smart.Format("There are {0:two} {0:links} in this one.", formatDelegate)
                        , Is.EqualTo("There are <a href='www.example.com/SomePage'>two</a> <a href='www.example.com/SomePage'>links</a> in this one."));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Junta os elementos de uma coleção em uma string, com o delimitador especificado.
        /// </summary>
        /// <param name="en">A coleção</param>
        /// <param name="delimiter">O delimitador</param>
        /// <param name="formatDelegate">O formatador</param>
        /// <returns>Uma string com a representação string de todos os objetos, separados pelo delimitador especificado</returns>
        public static string Join(IEnumerable en, string delimiter, FormatDelegate formatDelegate)
        {
            var sb = new StringBuilder();

            foreach (object obj in en)
            {
                sb.AppendFormat("{0}", formatDelegate(obj)).Append(delimiter);
            }
            if (sb.Length >= delimiter.Length)
            {
                sb.Length -= delimiter.Length;
            }
            return(sb.ToString());
        }
Ejemplo n.º 26
0
        public FormMain()
        {
            InitializeComponent();
            winFormRtbOutput = new WinFormRTBOutput(richTextBoxMessages);

            myTimer.Tick    += new EventHandler(TimerEventProcessor);
            myTimer.Interval = 2000;
            myTimer.Start();

            mobile.SmsProvider.SMSReceived += OnSmsReceived;

            formats    = new Formats();
            formatter += formats.FormatNone;
        }
        public static string Join <T>(IEnumerable <T> en, string delimiter, FormatDelegate <T> formatDelegate)
        {
            String.Join(delimiter, en.Select(s => formatDelegate(s)).ToArray());
            var sb = new StringBuilder();

            foreach (var obj in en)
            {
                sb.AppendFormat("{0}", formatDelegate(obj)).Append(delimiter);
            }
            if (sb.Length >= delimiter.Length)
            {
                sb.Length -= delimiter.Length;
            }
            return(sb.ToString());
        }
        public AnonymousTypeFormatter(
            FormatDelegate <T> format,
            string mimeType,
            Type type = null)
            : base(type)
        {
            if (string.IsNullOrWhiteSpace(mimeType))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(mimeType));
            }

            MimeType = mimeType;

            _format = format ?? throw new ArgumentNullException(nameof(format));
        }
Ejemplo n.º 29
0
        private void button1_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = "";
            switch (comboBox2.SelectedIndex)
            {
            case (0):
                _formatter = FormatTimeFirst;
                break;

            case (1):
                _formatter = FormatTimeLast;
                break;

            case (2):
                _formatter = FormatTimeFirstAndUpper;
                break;

            case (3):
                _formatter = FormatTimeLastAndUpper;
                break;
            }

            string   transmitter = comboBox1.SelectedItem.ToString();
            DateTime fromDate    = (DateTime)comboBox3.SelectedItem;
            DateTime toDate      = (DateTime)comboBox4.SelectedItem;
            string   search      = textBox3.Text;
            IEnumerable <Message> displayMessages;

            if (radioButton2.Checked)
            {
                displayMessages = DataSelector(mobile, transmitter, fromDate, toDate, search, "AND");
            }
            else
            {
                displayMessages = DataSelector(mobile, transmitter, fromDate, toDate, search, "OR");
            }

            foreach (var message in displayMessages)
            {
                string formattedMessage = _formatter(message);
                richTextBox1.AppendText(formattedMessage);
            }

            SmsFormatter();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Combines the input <paramref name="values"/> into a string separated by <paramref name="separator"/>
        /// and formatted using <paramref name="formatDelegate"/>; empty values are skipped when <paramref name="skipEmptyValues"/> is true.
        /// </summary>
        public static string Combine <T>(IEnumerable <T> values, string separator, FormatDelegate <T> formatDelegate, bool skipEmptyValues)
        {
            if (values == null)
            {
                return("");
            }

            if (separator == null)
            {
                separator = "";
            }

            StringBuilder builder = new StringBuilder();
            int           count   = 0;

            foreach (T value in values)
            {
                string stringValue;
                if (formatDelegate == null)
                {
                    stringValue = (value == null) ? "" : value.ToString();
                }
                else
                {
                    stringValue = formatDelegate(value) ?? "";
                }

                if (String.IsNullOrEmpty(stringValue) && skipEmptyValues)
                {
                    continue;
                }

                if (count++ > 0)
                {
                    builder.Append(separator);
                }

                builder.Append(stringValue);
            }

            return(builder.ToString());
        }
Ejemplo n.º 31
0
        public void ShowMessages(List <Message> messages)
        {
            var         selectedNumber = selectNumber?.SelectedItem?.ToString();
            var         minDate        = fromDate.Value;
            var         maxDate        = toDate.Value;
            var         filterMsg      = filterMessage?.Text?.ToString();
            var         filterLgc      = filterLogic?.Text?.ToString();
            FiltersFlds filterFlds     = new FiltersFlds(selectedNumber, minDate, maxDate, filterMsg, filterLgc);
            Filters     filter         = new Filters();
            var         query          = filter.GetFilter(filterFlds, messages);

            var selectedFormat = selectFormatting.SelectedItem.ToString();

            FormatterDel = GetFormatter(selectedFormat);
            foreach (var message in query)
            {
                var messageItem = new ListViewItem(new[] { message.User, message.Number, FormatterDel(message.Text), message.ReceivingTime.ToString() });
                OnSMSRecieved(messageItem);
            }
        }