Example #1
0
 public void SetTalker(ITalker talker)
 {
     _talker = talker;
     _talker.SpeakElementChanged += SelectCurrentElement;
     _talker.TextBaseLoaded      += LoadTextBase;
     LoadTextBase();
 }
Example #2
0
        /// <summary>
        /// もし <see cref="IProcessOperation"/> 実装クラスならば、
        /// すべてのモーダルウィンドウに WM_CLOSE メッセージを送信する。
        /// </summary>
        protected static void CloseAllModalsIfProcessOperation(ITalker talker)
        {
            try
            {
                var processOpe = talker as IProcessOperation;
                if (processOpe == null)
                {
                    return;
                }
                var mainWinHandle = processOpe.MainWindowHandle;
                if (mainWinHandle == IntPtr.Zero)
                {
                    return;
                }

                using (var app = new WindowsAppFriend(mainWinHandle))
                {
                    while (true)
                    {
                        var topWin = WindowControl.FromZTop(app);

                        // メインウィンドウなら処理終了
                        if (topWin == null || topWin.Handle == mainWinHandle)
                        {
                            break;
                        }

                        topWin.SendMessage(WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
                    }
                }
            }
            catch { }
        }
Example #3
0
        public TalkerController(ITalker talker, ITalkerView view, ISettingsManager settingsManager)
        {
            _talker          = talker;
            _view            = view;
            _settingsManager = settingsManager;

            Init();
        }
        public ReaderMethod()
        {
            this.italker = new Talker();

            italker.MessageReceived += new MessageReceivedEventHandler(ReceivedTcpData);

            iSerialPort = new SerialPort();

            iSerialPort.DataReceived += new SerialDataReceivedEventHandler(ReceivedComData);
        }
        public ReaderMethod()
        {
            this.italker = new Talker();

            italker.MessageReceived += new MessageReceivedEventHandler(ReceivedTcpData);

            iSerialPort = new SerialPort();

            iSerialPort.DataReceived+=new SerialDataReceivedEventHandler(ReceivedComData);
        }
Example #6
0
 public void Restore(ITalker talker)
 {
     talker.Interval = Properties.Settings.Default.Interval;
     talker.Random   = Properties.Settings.Default.Random;
     talker.Repeat   = Properties.Settings.Default.Repeat;
     talker.Speed    = Properties.Settings.Default.Speed;
     talker.Volume   = Properties.Settings.Default.Volume;
     talker.Voice    = Properties.Settings.Default.Voice;
     talker.Timbre   = Properties.Settings.Default.Timbre;
     _recentFiles    = new List <string>((Properties.Settings.Default.RecentFiles ?? new StringCollection()).Cast <string>());
 }
Example #7
0
        public void SetTalker(ITalker talker)
        {
            _talker = talker;
            _talker.StateChanged += _ => UpdateControls();
            _talker.ReadyChanged += _ => UpdateControls();

            InitControls();
            UpdateControls();
            UpdateLabelSpeed();
            UpdateLabelVolume();
            UpdateLabelTimbre();
            UpdateRecentFiles(RecentFiles);
        }
Example #8
0
        public void Save(ITalker talker)
        {
            Properties.Settings.Default.Interval = talker.Interval;
            Properties.Settings.Default.Random   = talker.Random;
            Properties.Settings.Default.Repeat   = talker.Repeat;
            Properties.Settings.Default.Speed    = talker.Speed;
            Properties.Settings.Default.Volume   = talker.Volume;
            Properties.Settings.Default.Voice    = talker.Voice;
            Properties.Settings.Default.Timbre   = talker.Timbre;

            StringCollection files = new StringCollection();

            files.AddRange(_recentFiles.ToArray());
            Properties.Settings.Default.RecentFiles = files;

            Properties.Settings.Default.Save();
        }
Example #9
0
        /// <summary>
        /// もし <see cref="IProcessOperation"/> 実装クラスならば、
        /// すべてのネイティブモーダルウィンドウの先頭ボタンをクリックする。
        /// </summary>
        protected static void ClickAllModalsFirstButtonIfProcessOperation(ITalker talker)
        {
            try
            {
                var processOpe = talker as IProcessOperation;
                if (processOpe == null)
                {
                    return;
                }
                var mainWinHandle = processOpe.MainWindowHandle;
                if (mainWinHandle == IntPtr.Zero)
                {
                    return;
                }

                using (var app = new WindowsAppFriend(mainWinHandle))
                {
                    while (true)
                    {
                        var topWin = WindowControl.FromZTop(app);

                        // メインウィンドウなら処理終了
                        if (topWin == null || topWin.Handle == mainWinHandle)
                        {
                            break;
                        }

                        // ネイティブボタンがあればクリック
                        var natives = topWin.GetFromWindowClass(@"Button");
                        if (natives.Length > 0)
                        {
                            new NativeButton(natives[0]).EmulateClick();
                        }
                    }
                }
            }
            catch { }
        }
Example #10
0
        static void Main(string[] args)
        {
            //注册通道
            TcpClientChannel channel = new TcpClientChannel();

            ChannelServices.RegisterChannel(channel, true);

            talkerClient = (ITalker)Activator.GetObject(
                typeof(ITalker), "tcp://localhost:8090/Talker");
            Console.WriteLine("talker 远程对象激活成功。!");

            vessel = (IVessel)Activator.GetObject(
                typeof(IVessel), "tcp://localhost:8091/H3BPMSERVER");
            Console.WriteLine("vessel 远程对象激活成功。!");

            while (true)
            {
                Console.WriteLine("1,直接执行简单Remoting调用。");
                Console.WriteLine("2,执行复杂Remoting调用。");

                string keyboard = Console.ReadLine();

                switch (keyboard)
                {
                case "1":
                    InvokeRemoting();
                    break;

                case "2":
                    InvokeH3Remoting();
                    break;

                default:
                    break;
                }
            }
        }
Example #11
0
        private void ServiceControllerPoller()
        {
            if (configurationData == null)
                ServiceActive = false;
            else if (configurationData.Settings.RemoteServiceAddress != "")
            {
                try
                {
                    if (talker == null || !talker.Connected)
                    {
                        if(Listener.IsLocal(configurationData.Settings.RemoteServiceAddress))
                            talker = new MessageQueueTalker(Namespace.Client);
                        else
                            talker = new TcpTalker(configurationData.Settings.RemoteServiceAddress);
                    }

                    talker.SendCommand(new Command { CommandType = Commands.ServiceStatus, Data = null, ToNamespace = Namespace.Service });

                }
                catch (Exception ex)
                {
                    Logger.Instance.LogException(this.GetType(), ex);
                    Invoke(new UpdateLogDelegate(UpdateLog), "Unable to connect to Service machine: network monitor service status unknown");
                    statusBarLabelServiceStatus.Text = "Service Status: Unknown";
                    ServiceActive = false;
                    synced = false;
                    statusBarLabelMonitoringStatus.Text = "Monitoring Status: Locally";
                }
            }
        }
Example #12
0
        private void ShowSettings()
        {
            try
            {
                Settings settings = new Settings();

                if (notifySettings != null)
                {
                    settings.settingsRemoteMonServiceAddressTextBox.Text = notifySettings.ServiceAddress;
                    settings.settingsRemoteMonServicePortTextBox.Text = notifySettings.ServicePort.ToString();
                }
                DialogResult dr = settings.ShowDialog();

                if (dr == DialogResult.OK)
                {
                    if (notifySettings == null)
                        notifySettings = new NotifySettings();
                    notifySettings.ServiceAddress = settings.settingsRemoteMonServiceAddressTextBox.Text;
                    Int32 port;
                    if (Int32.TryParse(settings.settingsRemoteMonServicePortTextBox.Text, out port))
                        notifySettings.ServicePort = port;

                    if (Listener.IsLocal(notifySettings.ServiceAddress))
                        talker = new MessageQueueTalker(Namespace.Notifier);
                    else
                        talker = new TcpTalker(notifySettings.ServiceAddress, thisNamespace: Namespace.Notifier);

                    notifySettings.ExportToXml("settings.xml");
                }
            }
            catch(Exception ex)
            {
                Logger.Instance.LogException(this.GetType(), ex);
            }
        }
Example #13
0
 /// <summary>
 /// パラメータ群を設定する。
 /// </summary>
 /// <param name="talker"><see cref="ITalker"/> オブジェクト。</param>
 /// <param name="parameters">設定するパラメータIDとその値の列挙。</param>
 /// <returns>
 /// 個々のパラメータIDとその設定成否を保持するディクショナリ。
 /// 処理を行えない状態ならば null 。
 /// </returns>
 /// <remarks>
 /// 設定処理自体行われなかったパラメータIDは戻り値のキーに含まれない。
 /// </remarks>
 public static Result <Dictionary <object, Result <bool> > > SetParameters(
     this ITalker talker,
     IEnumerable <(object id, decimal value)> parameters)
Example #14
0
 public Minifigure(ITalker head, Torso torso, Legs legs)
 {
     _head  = head;
     _torso = torso;
     _legs  = legs;
 }
Example #15
0
 //[Adsorber(typeof(TalkerAdsorber), "SupplyEvent")]
 public void Supply(ITalker talker)
 {
     Name = talker.Name;
     Chat.Join(talker.Name);
 }
Example #16
0
 public Minifigure(ITalker talker, Torso torso, Legs legs)
 {
     _talker = talker;
     _torso  = torso;
     _legs   = legs;
 }
Example #17
0
 private void LoadSettings()
 {
     try
     {
         notifySettings = NotifySettings.LoadSettings("settings.xml");
         if (notifySettings != null)
         {
             if (Listener.IsLocal(notifySettings.ServiceAddress))
                 talker = new MessageQueueTalker(Namespace.Notifier);
             else
                 talker = new TcpTalker(notifySettings.ServiceAddress, thisNamespace: Namespace.Notifier);
         }
     }
     catch(Exception ex)
     {
         Logger.Instance.LogException(this.GetType(), ex);
     }
 }
Example #18
0
        private void PopulateConfigurationData(Boolean retry)
        {
            if (!File.Exists(_configPath))
            {
                NoConfigurationFound noConfigurationFound = new NoConfigurationFound();
                DialogResult dialogResult = noConfigurationFound.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    if (noConfigurationFound.File)
                    {
                        _configPath = noConfigurationFound.FileName;
                    }
                    else
                    {
                        if (Listener.IsLocal(noConfigurationFound.IpOrHostName))
                            talker = new MessageQueueTalker(Namespace.Client);
                        else
                            talker = new TcpTalker(noConfigurationFound.IpOrHostName, connectPort: noConfigurationFound.Port);

                        talker.SendCommand(new Command { CommandType = Commands.GetConfiguration, Data = null, ToNamespace = Namespace.Service });
                        return;
                    }
                }
            }

            try
            {
                if (!Directory.Exists(_path))
                    Directory.CreateDirectory(_path);

                if (!File.Exists(_configPath))
                    //NOTE: Create a blank configuration.xml file
                    CreateConfigurationXml();

                configurationData = ConfigurationData.LoadConfiguration(_configPath);
                configurationLoaded = true;

                if (configurationData.Settings.ClientLogPath != "")
                {
                    _logPath = configurationData.Settings.ClientLogPath;
                    Logger.Instance.SetFileName(_logPath);
                }
            }
            catch (Exception ex)
            {
                if (retry && (ex.InnerException != null && ex.InnerException.Message == "Root element is missing."))
                {
                    File.Delete(_configPath); //NOTE: should I be doing this?
                    PopulateConfigurationData(false);
                }
                else
                {
                    Logger.Instance.LogException(this.GetType(), ex);
                    MessageBox.Show("Error loading configuration file - check log for details.", "Error");
                }
            }
        }
Example #19
0
 public Task AppendMessage(ITalker talker, string msg)
 {
     var name = talker.GetPrimaryKeyString();
     _subscribers.Notify(x => x.AppendMessage(name, msg));
     return TaskDone.Done;
 }