Example #1
0
 private void SetControlFonts()
 {
     this.Font = Helper.SystemFont;
     rtbMessageHistory.Font = Definitions.GetPresetFont(FormatTypes.Message);
     rtbMessage.Font        = Definitions.GetPresetFont(FormatTypes.Message);
     btnSendMessage.Font    = new Font(Helper.SystemFont.FontFamily, 11.25f, FontStyle.Bold);
     lblUserAction.Font     = SystemFonts.StatusFont;
 }
Example #2
0
        /// <summary>
        /// Adds an entry to the chat history box.
        /// </summary>
        /// <param name="text">The text to be added.</param>
        private void UpdateChatHistory(string text, FormatTypes formatType)
        {
            //  This code block ensures optimum line spacing between different types of formatted texts.
            switch (lastFormatType)
            {
            case FormatTypes.Status:
                if (formatType != FormatTypes.Status)
                {
                    rtbMessageHistory.AppendTextAsRtf("\n");
                }
                break;

            case FormatTypes.Message:
                if (formatType != FormatTypes.UserName)
                {
                    rtbMessageHistory.AppendTextAsRtf("\n");
                }
                break;
            }
            lastFormatType = formatType;

            //  Ensure there is no more than one blank line between messages.
            if (text.StartsWith(Environment.NewLine))
            {
                if (rtbMessageHistory.Text.EndsWith("\n\n"))
                {
                    text = text.TrimStart(Environment.NewLine.ToCharArray());
                }
            }

            switch (formatType)
            {
            case FormatTypes.UserName:
            case FormatTypes.Status:
                rtbMessageHistory.AppendTextAsRtf(text, Definitions.GetPresetFont(formatType), Definitions.GetPresetColor(formatType));
                break;

            case FormatTypes.Message:
                string rtfText = DecodeEmoticons(text);
                rtfText = rtfText.Insert(rtfText.LastIndexOf(@"\f0"), @"\li240");
                rtbMessageHistory.AppendRtf(rtfText);

                //  Enable button that saves chat history.
                if (!bCanSave && rtbMessageHistory.TextLength > 0)
                {
                    tbBtnSave.Enabled = true;
                    bCanSave          = true;
                }
                break;

            default:
                rtbMessageHistory.AppendTextAsRtf(text);
                break;
            }

            //  For auto scrolling chat history box.
            rtbMessageHistory.ScrollToBottom();
        }
Example #3
0
        /// <summary>
        /// Load settings from the settings file. This method also checks if all files needed by
        /// the application is present.
        /// </summary>
        /// <returns></returns>
        private bool LoadSettings()
        {
            try {
                int iConfigVersion = Properties.Settings.Default.ConfigVersion;

                //  The broadcast address.
                broadcastAddress = IPAddress.Parse(Properties.Settings.Default.BroadcastAddress);

                //  The port to be used for sending and receiving. Stored in settings.
                //  Do not change port number once Sockets have been bound.
                if (receiveUdpClient == null)
                {
                    portNumber = Properties.Settings.Default.UDPPort;
                }

                //  Flag to determine if system tray notifications should be displayed.
                bShowNotifications = Properties.Settings.Default.ShowSysTrayNotify;

                //  Set silent mode according to the stored settings.
                SetSilentMode(Properties.Settings.Default.SilentMode);

                //  Status of local user.
                localStatus = Properties.Settings.Default.UserStatus;

                bBkgndMessageShown = !Properties.Settings.Default.ShowMinimizeMessage;

                //  Flag to determine if new conversations should be opened in tabs or windows.
                bChatWindowed = Properties.Settings.Default.ChatWindowed;

                //  Set visual style according to theme.
                SetTheme(Properties.Settings.Default.UseThemes, Properties.Settings.Default.ThemeFile);

                //  Flag to determine window behavior for new incoming message.
                bMessageToForeground = Properties.Settings.Default.MessageToForeground;

                //  Flags for alerts and sounds.
                bDisplayAlerts       = Properties.Settings.Default.DisplayAlerts;
                bSuspendAlertsOnBusy = Properties.Settings.Default.SuspendAlertsOnBusy;
                bSuspendAlertsOnDND  = Properties.Settings.Default.SuspendAlertsOnDND;
                bPlaySounds          = Properties.Settings.Default.PlaySounds;
                bSuspendSoundsOnBusy = Properties.Settings.Default.SuspendSoundsOnBusy;
                bSuspendSoundsOnDND  = Properties.Settings.Default.SuspendSoundsOnDND;

                //  Connection time out period in seconds.
                connectionTimeout = Properties.Settings.Default.ConnectionTimeOut;

                //  Number of retries if connection dropped.
                connectionRetries = Properties.Settings.Default.ConnectionRetries;

                //  Time period before the user list is updated automatically.
                userRefreshPeriod        = Properties.Settings.Default.UserRefreshPeriod;
                timerUserUpdate.Interval = userRefreshPeriod * 1000;

                //  Time period after which system is considered idle.
                //  Convert property value from minutes to milliseconds.
                idleTimeMax = Properties.Settings.Default.IdleTimeMins * 60 * 1000;

                //  Default font used for messaging.
                defaultFont = Properties.Settings.Default.DefaultFont;
                if (defaultFont == null)
                {
                    Properties.Settings.Default.DefaultFont = Definitions.GetPresetFont(FormatTypes.Message);
                }

                //  Color of default font.
                defaultFontColor = Properties.Settings.Default.DefaultFontColor;

                //  Folder for storing received files. If it is not set, assign default value.
                string receivedFileFolder = Properties.Settings.Default.ReceivedFileFolder;
                if (receivedFileFolder.Equals(string.Empty))
                {
                    Properties.Settings.Default.ReceivedFileFolder = AppInfo.ReceivedFilePath;
                }

                //  Load chat settings and apply to all the Chat controls inside tab pages/chat windows.
                LoadChatSettings();

                return(true);
            }
            catch (Exception ex) {
                ErrorHandler.ShowError(ex);
                return(false);
            }
        }