コード例 #1
0
        public bool Show(Equipment.EquipmentBase equipment, string name, string message, System.Windows.Media.ImageSource image, bool useSound, Module.StateSignalModule stateSignalModule, ConfigClasses.EquipmentStateConfig stateConfig)
        {
            bool result = false;

            App.Current.Dispatcher.Invoke(
                new Action(
                    delegate()
                    {
                        if (_messageWindowList.ContainsKey(name) == false)
                        {
                            _messageWindowList.Add(name, new MessageWindowInfo(null, stateSignalModule));
                        }

                        _messageWindowList[name].StateSignalModule = stateSignalModule;

                        bool customSoundMode = false;
                        if (stateSignalModule != null && stateConfig != null)
                        {
                            try
                            {
                                customSoundMode = true;
                                stateConfig.CopyTo(stateSignalModule.CustomState);
                            }
                            catch
                            {
                            }
                        }

                        var windowInfo = _messageWindowList[name];
                        var window = _messageWindowList[name].WindowInstance;

                        if (window == null ||
                            window.IsLoaded == false)
                        {
                            equipment.StateSignalModuleReferance.OffSound = false;

                            var messageWindow = new MessageWindow();
                            windowInfo.WindowInstance = messageWindow;

                            messageWindow.EquipmentInstance = equipment;
                            messageWindow.RaisedTime = DateTime.Now;
                            messageWindow.Message = message;
                            messageWindow.Caption = name;
                            messageWindow.ImageSource = image;

                            messageWindow.UseSound = useSound;
                            messageWindow.UseCustomSound = customSoundMode;

                            messageWindow.Owner = equipment.Window;
                            messageWindow.OnCloseWindow +=
                                delegate
                                {
                                    if (stateSignalModule != null)
                                    {
                                        stateSignalModule.CustomMode = false;
                                    }
                                };
                            messageWindow.Show();

                            result = true;
                        }
                        else if (window.Message != message)
                        {
                            var messageWindow = windowInfo.WindowInstance;
                            messageWindow.RaisedTime = DateTime.Now;
                            messageWindow.Message = message;
                            messageWindow.Caption = name;
                            messageWindow.ImageSource = image;
                            messageWindow.Owner = equipment.Window;
                            messageWindow.UseSound = useSound;

                            result = true;
                        }
                        else
                            result = false;

                        if (stateSignalModule != null)
                        {
                            stateSignalModule.CustomMode = true;
                        }

                        if (equipment != null && result == true)
                            LogManager.Instance.WriteTraceLog(equipment, string.Format("MESSAGE : CAPTION = {0}, MESSAGE = {1}", name, message));
                    }));

            return result;
        }
コード例 #2
0
        public bool Show(System.Windows.Window owner, string name, string message)
        {
            bool result = false;

            App.Current.Dispatcher.Invoke(
                new Action(
                    delegate()
                    {
                        if (_messageWindowList.ContainsKey(name) == false)
                        {
                            _messageWindowList.Add(name, new MessageWindowInfo(null, null));
                        }

                        var windowInfo = _messageWindowList[name];
                        var window = _messageWindowList[name].WindowInstance;

                        if (window == null ||
                            window.IsLoaded == false)
                        {
                            var messageWindow = new MessageWindow();
                            windowInfo.WindowInstance = messageWindow;

                            messageWindow.EquipmentInstance = null;
                            messageWindow.RaisedTime = DateTime.Now;
                            messageWindow.Message = message;
                            messageWindow.Caption = name;
                            messageWindow.UseSound = false;
                            messageWindow.Owner = owner;
                            messageWindow.Show();

                            result = true;
                        }
                        else if (window.Message != message)
                        {
                            var messageWindow = _messageWindowList[name].WindowInstance;
                            messageWindow.RaisedTime = DateTime.Now;
                            messageWindow.Message = message;
                            messageWindow.Caption = name;
                            messageWindow.UseSound = false;

                            result = true;
                        }
                        else
                            result = false;
                    }));

            return result;
        }