Esempio n. 1
0
        private void commentNameField_TextChanged(object sender, TextChangedEventArgs e)
        {
            string name = commentNameField.Text;

            new Thread(() =>
            {
                var DataKit        = new DataKit();
                var monitorSetting = (from c in DataKit.Realm.All <CommentSettingsByMonitor>() where c.MonitorDeviceName == MainWindow.MonitorDeviceName select c).First();

                DataKit.Realm.Write(() =>
                {
                    monitorSetting.Name = name;
                });
            }).Start();

            try
            {
                HangulKit.HANGUL_INFO partOfName = HangulKit.HangulJaso.DevideJaso(commentNameField.Text[commentNameField.Text.Length - 1]);
                if (partOfName.chars[2] == ' ')
                {
                    nameJongsungText.Content = "야, ";
                }
                else
                {
                    nameJongsungText.Content = "아, ";
                }
            }
            catch (NullReferenceException ee)
            {
            }
            catch (IndexOutOfRangeException ee)
            {
            }
        }
        private static void MainThread()
        {
            var DataKit = new DataKit();

            while (true)
            {
                try
                {
                    DataKit.Realm.Refresh();

                    var clockSetting   = DataKit.Realm.All <ClockSettingsByMonitor>().Where(c => c.MonitorDeviceName == MonitorDeviceName).First();
                    var commentSetting = DataKit.Realm.All <CommentSettingsByMonitor>().Where(c => c.MonitorDeviceName == MonitorDeviceName).First();

                    int  clockSize      = clockSetting.ClockSize;
                    bool isWhiteClick   = clockSetting.IsWhiteClock;
                    int  clockDirection = commentSetting.DirectionOfComment;

                    string name    = commentSetting.Name;
                    string comment = commentSetting.Comment;

                    bool isEnabledCommentLoadFromServer = commentSetting.IsEnabledLoadFromServer;
                    bool isUseCommentInName             = commentSetting.IsEnabledNameInComment;

                    if (isEnabledCommentLoadFromServer)
                    {
                        message = loadCommentFromServer();
                    }
                    else
                    {
                        message = comment;
                        lastCommentRequestTime = DateTime.MinValue;
                    }

                    try
                    {
                        if (isUseCommentInName)
                        {
                            HangulKit.HANGUL_INFO partOfName = HangulKit.HangulJaso.DevideJaso(name[name.Length - 1]);
                            if (partOfName.chars[2] == ' ')
                            {
                                comment = String.Format("{0}야, {1}", name, message);
                            }
                            else
                            {
                                comment = String.Format("{0}아, {1}", name, message);
                            }
                        }
                        else
                        {
                            comment = message;
                        }
                    }
                    catch (Exception e)
                    {
                    }

                    hangulClockDesktop.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
                    {
                        hangulClockDesktop.ucScale.ScaleX = (double)clockSize / 100;
                        hangulClockDesktop.ucScale.ScaleY = (double)clockSize / 100;

                        hangulClockDesktop.SetClockColor(isWhiteClick);

                        if (clockDirection == CommentSettingsByMonitor.CommentDirection.TOP)
                        {
                            hangulClockDesktop.setTopCommentText(comment);
                        }
                        else if (clockDirection == CommentSettingsByMonitor.CommentDirection.LEFT)
                        {
                            hangulClockDesktop.setLeftCommentText(comment);
                        }
                        else if (clockDirection == CommentSettingsByMonitor.CommentDirection.RIGHT)
                        {
                            hangulClockDesktop.setRightCommentText(comment);
                        }
                        else
                        {
                            hangulClockDesktop.setBottomCommentText(comment);
                        }
                    }));

                    Thread.Sleep(5000);
                }
                catch (ThreadInterruptedException e)
                {
                }
            }
        }