Exemplo n.º 1
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability (capability);

            if (fileTransferCapability == null)
                fileTransferCapability = (FileTransferCapability)capability;
        }
Exemplo n.º 2
0
        private void InitVideoCapability(ICapability capability)
        {
            if (videoCapability == null)
            {
                videoCapability = (VideoCapability)capability;

                this.Text = videoCapability.Name;

                // Unintuitively causes us to look at the vidSrcRatio and use it if it's been set
                TrimBlackFromVideo(base.Size);

                // TODO: Add a condition to not call InitVideoUI() if isFormLoaded is false to prevent
                // the form to show to early
                InitVideoUI();

                videoCapability.VideoWindowHandle       = pbVideo.Handle;
                videoCapability.VideoWindowMessageDrain = pbVideo.Handle;
                videoCapability.ResizeVideoStream(pbVideo.Height, pbVideo.Width);
                //videoCapability.ResizeVideoStream(230, 200);

                // Set the UI borders so the video capability can calculate the
                // AV form size given some constrains due to the video ratio
                //videoCapability.UIBorderWidth = UIBorderWidth;
                //videoCapability.UIBorderHeight = UIBorderHeight;
            }
        }
Exemplo n.º 3
0
 internal CFileSystem(CItem parent, ICapability capability) : base(parent)
 {
     if (!(parent is CSource))
     {
         throw new Exception("Internal error");
     }
     this.MedFileSystem = (IFileSystem)capability;
     try
     {
         this.MIDP = (CFileSystem.EMIDP) this.MedFileSystem.MIDP;
     }
     catch (Exception ex)
     {
         Console.WriteLine(this.ToString() + " : Unable to query MIDP version [ " + ex.Message + " ]");
     }
     try
     {
         this.RootFolder = new CFolder(this, (IFolder)this.MedFileSystem.GetFolder("\\"));
     }
     catch (Exception ex2)
     {
         this.RootFolder = null;
         Console.WriteLine(this.ToString() + " : Unable to query root folder [ " + ex2.Message + " ]");
     }
 }
Exemplo n.º 4
0
        private void InitAudioCapability(ICapability capability)
        {
            if (audioCapability == null)
            {
                audioCapability = (AudioCapability)capability;

                // We want always to have the name of the video capability
                // if the form is shared with a video capability
                // => If the audio capability come after the video capability,
                // we want to overwrite with the name of the video capability.
                if (videoCapability != null)
                {
                    this.Text = videoCapability.Name;
                }

                // TODO: Add a condition to not call InitVideoUI() if isFormLoaded is false to prevent
                // the form to show to early
                InitAudioUI();

                // Set the UI borders so the audio capability can calculate the
                // AV form size given some constrains due to the video ratio
                //audioCapability.UIBorderWidth = UIBorderWidth;
                //audioCapability.UIBorderHeight = UIBorderHeight;
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Add a rule that target Capability shall be failed in case of a NOK monitoring result
 /// </summary>
 /// <param name="degrader">Degrader being used to add the rule</param>
 /// <param name="failure"></param>
 /// <param name="targetCapability"></param>
 public static void AddRuleForFailure(
     this IDegrader degrader,
     IFailure failure,
     ICapability targetCapability)
 {
     degrader.AddRule(failure, MonitoringResult.NOK, targetCapability, Capabilities.Failed);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Add a rule that target Capability shall be unknown in case of a unknown monitoring result
 /// </summary>
 /// <param name="degrader">Degrader being used to add the rule</param>
 /// <param name="failure"></param>
 /// <param name="targetCapability"></param>
 public static void AddRuleForUnknown(
     this IDegrader degrader,
     IFailure failure,
     ICapability targetCapability)
 {
     degrader.AddRule(failure, MonitoringResult.Unknown, targetCapability, Capabilities.Unknown);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Adds a rule that the target capability shall be set to unknown in case the source capability is unknown
 /// </summary>
 /// <param name="degrader">Degrader being used to add the rule</param>
 /// <param name="sourceCapability">Source capability that is triggering the change of the targetCapability</param>
 /// <param name="targetCapability">The target capability that will be updated</param>
 public static void AddRuleForUnknown(
     this IDegrader degrader,
     ICapability sourceCapability,
     ICapability targetCapability)
 {
     degrader.AddRule(sourceCapability, Capabilities.Unknown, targetCapability, Capabilities.Unknown);
 }
Exemplo n.º 8
0
        public void TestSingleDegrader()
        {
            var degrader           = new Degrader("All");
            var monitorPowerSupply = new PowerSupplyMonitor(degrader);

            _capabilityPowerSupply = new Capability(degrader, "Power Supply");

            var monitorActuator = new ActuatorMonitor(degrader);

            _capabilityActuator = new Capability(degrader, "Actuator");

            _capabilitySystem = new Capability(degrader, "System");

            degrader.AddDefaultRules(monitorPowerSupply.TotalFailure, _capabilityPowerSupply);
            degrader.AddDefaultRules(monitorActuator.TotalFailure, _capabilityActuator);
            degrader.AddDefaultRules(_capabilityPowerSupply, _capabilityActuator);
            degrader.AddDefaultRules(_capabilityActuator, _capabilitySystem);

            degrader.AddTrigger(_capabilitySystem,
                                x => Console.WriteLine($"- System: {Capabilities.Convert(x.Current)}"));

            GiveStatus();
            Console.WriteLine("Pass Power Supply...");
            monitorPowerSupply.MakeOk();
            GiveStatus();
            Console.WriteLine("Pass Power Actuator...");
            monitorActuator.MakeOk();
            GiveStatus();

            Assert.That(_capabilitySystem.Current, Is.EqualTo(Capabilities.Full));
        }
Exemplo n.º 9
0
        public override bool RemoveCapability(ICapability capability)
        {
            bool ret = base.RemoveCapability(capability);

            if (ret)
            {
                if (fgm != null)
                {
                    fgm.Stop();
                    FilterGraph.RemoveFromRot(rotID);
                    FilterGraph.RemoveAllFilters(fgm);
                    fgm = null;
                }

                if (fgmEventMonitor != null)
                {
                    fgmEventMonitor.FgmEvent -= new FgmEventMonitor.FgmEventHandler(FgmEvent);
                    fgmEventMonitor.Dispose();
                    fgmEventMonitor = null;
                }

                wmf = null;
            }

            return(ret);
        }
Exemplo n.º 10
0
        public async Task <DeviceCapabilityDescriptor> RegisterCapability(ICapability capability)
        {
            var descriptor = CapabilityDescriber.Describe(capability);

            foreach (var action in descriptor.Actions)
            {
                action.MqttTopic = $"action/+/{_mqttClientService.DeviceId}/{capability.CapabilityId}/{action.Name}";
                if (!await _mqttClientService.Subscribe(
                        action.MqttTopic,
                        action.Method,
                        capability))
                {
                    //TODO: Failure to subscribe??
                }
            }

            foreach (var property in descriptor.Properties)
            {
                property.MqttTopic = $"value/+/{_mqttClientService.DeviceId}/{capability.CapabilityId}/{property.Name}";

                if (!await _mqttClientService.Subscribe(
                        property.MqttTopic,
                        property.Property.GetMethod,
                        capability))
                //TODO: What about set method?
                {
                    //TODO: fialure
                }
            }
            //TODO: Register events

            return(descriptor);
        }
Exemplo n.º 11
0
        private static ActuatorMonitor CreateSup(IDegrader degrader, ICapability capability, int i)
        {
            ActuatorMonitor last = null;

            for (var n = 0; n < 5; n++)
            {
                var subDegrader   = new Degrader("Sub");
                var subCapability = new Capability(subDegrader, "Sub");

                var failure = new ActuatorMonitor(subDegrader);
                subDegrader.AddDefaultRules(failure.TotalFailure, subCapability);
                degrader.AddDefaultRules(subCapability, capability);

                if (i < 5)
                {
                    last = CreateSup(subDegrader, subCapability, i + 1);
                }
                else
                {
                    last = failure;
                }

                failure.MakeOk();
            }

            return(last);
        }
Exemplo n.º 12
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.Status == null))
                {
                    IStatus statusCasted = item.As <IStatus>();
                    if ((statusCasted != null))
                    {
                        this._parent.Status = statusCasted;
                        return;
                    }
                }
                IErpPerson erpPersonsCasted = item.As <IErpPerson>();

                if ((erpPersonsCasted != null))
                {
                    this._parent.ErpPersons.Add(erpPersonsCasted);
                }
                ISkill skillsCasted = item.As <ISkill>();

                if ((skillsCasted != null))
                {
                    this._parent.Skills.Add(skillsCasted);
                }
                ICapability capabilitiesCasted = item.As <ICapability>();

                if ((capabilitiesCasted != null))
                {
                    this._parent.Capabilities.Add(capabilitiesCasted);
                }
            }
Exemplo n.º 13
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                if ((this._parent.Status == item))
                {
                    this._parent.Status = null;
                    return(true);
                }
                IErpPerson erpPersonItem = item.As <IErpPerson>();

                if (((erpPersonItem != null) &&
                     this._parent.ErpPersons.Remove(erpPersonItem)))
                {
                    return(true);
                }
                ISkill skillItem = item.As <ISkill>();

                if (((skillItem != null) &&
                     this._parent.Skills.Remove(skillItem)))
                {
                    return(true);
                }
                ICapability capabilityItem = item.As <ICapability>();

                if (((capabilityItem != null) &&
                     this._parent.Capabilities.Remove(capabilityItem)))
                {
                    return(true);
                }
                return(false);
            }
Exemplo n.º 14
0
 /// <summary>
 /// Adds the information that the given capability is dependent on the this capability.
 /// This means that if the this capability is updated, the dependent capabilities also have to be updated
 /// </summary>
 /// <param name="capability">Capability which needs to be updated in case of an update of this capability</param>
 public void AddDependent(ICapability capability)
 {
     if (!DependentCapabilities.Contains(capability))
     {
         DependentCapabilities.Add(capability);
     }
 }
 internal CapabilityViewModel(ICapability capability)
 {
     CapabilityReference = capability.CapabilityReference;
     Version             = capability.Version;
     Name         = capability.Name;
     IsFoundation = capability.IsFoundation;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Adds a rule, that the target Capability shall be Failed in case of a degraded source Capability
 /// </summary>
 /// <param name="degrader">Degrader being used to add the rule</param>
 /// <param name="sourceCapability"></param>
 /// <param name="targetCapability"></param>
 public static void AddRuleForFailure(
     this IDegrader degrader,
     ICapability sourceCapability,
     ICapability targetCapability)
 {
     degrader.AddRule(sourceCapability, Capabilities.Failed, targetCapability, Capabilities.Failed);
 }
Exemplo n.º 17
0
 private void CheckThatInDegrader(ICapability capability)
 {
     if (capability.Degrader != this)
     {
         throw new InvalidOperationException(
                   $"Given capability {capability} does not match to Degrader {this}");
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Adds a default rule to set the target capability to Failed or Unknown depending on the failure.
 /// NOK will be mapped to Failed, Unknown will be mapped to Unknown
 /// If additional relationships need to be established, further explicit calls are necessary
 /// </summary>
 /// <param name="degrader">Degrader to be used for the rule</param>
 /// <param name="failure">The falilue whose change will have an effect on the <c>targetCapability</c></param>
 /// <param name="targetCapability">The targetcapability being used</param>
 public static void AddDefaultRules(
     this IDegrader degrader,
     IFailure failure,
     ICapability targetCapability)
 {
     AddRuleForFailure(degrader, failure, targetCapability);
     AddRuleForUnknown(degrader, failure, targetCapability);
 }
Exemplo n.º 19
0
        public override bool RemoveCapability(ICapability capability)
        {
            bool ret = base.RemoveCapability (capability);
            fileTransferCapability = null;
            this.Close();

            return ret;
        }
Exemplo n.º 20
0
        public static DeviceCapabilityDescriptor Describe(ICapability capability)
        {
            var actionMethods = capability.GetType().GetMethods().Where(info =>
                                                                        info.CustomAttributes.Any(attribute => attribute.AttributeType == typeof(ActionAttribute)));

            var actions = new List <DeviceCapabilityDescriptor.ActionDescriptor>();

            foreach (var actionMethod in actionMethods)
            {
                var parameters = actionMethod
                                 .GetParameters()
                                 .Select(param =>
                                         new DeviceCapabilityDescriptor.ValueDescriptor(
                                             param.Name,
                                             param.ParameterType.Name)
                                         ).ToArray();

                var descriptor = new DeviceCapabilityDescriptor.ActionDescriptor(
                    actionMethod.Name,
                    parameters,
                    actionMethod.ReturnType.Name
                    )
                {
                    Method = actionMethod
                };

                actions.Add(descriptor);
            }

            var valueProperties = capability
                                  .GetType()
                                  .GetProperties()
                                  .Where(info =>
                                         info
                                         .CustomAttributes
                                         .Any(attribute =>
                                              attribute.AttributeType == typeof(ValueAttribute)
                                              )
                                         );

            var values = new List <DeviceCapabilityDescriptor.PropertyDescriptor>();

            foreach (var valueProperty in valueProperties)
            {
                var descriptor = new DeviceCapabilityDescriptor.PropertyDescriptor(
                    valueProperty.Name,
                    valueProperty.PropertyType.Name,
                    true)
                {
                    Property = valueProperty
                };

                values.Add(descriptor);
            }
            //TODO: Register events

            return(new DeviceCapabilityDescriptor(capability.CapabilityId, capability.CapabilityTypeId, values.ToArray(), actions.ToArray()));
        }
Exemplo n.º 21
0
 public IListContract<IParamType> Invoke(string roleName, string opName, IListContract<IParamType> parameters, IPort p, ICapability reqCap, ICapability respCap)
 {
     return CollectionAdapters.ToIListContract<VParamType, IParamType>(_view.Invoke(roleName, opName, 
                                                                                                CollectionAdapters.ToIList<IParamType, VParamType>(parameters, BaseTypeAdapter.C2V, BaseTypeAdapter.V2C),
                                                                                                PortAdapter.C2V(p), 
                                                                                                CapabilityAdapter.C2V(reqCap), 
                                                                                                CapabilityAdapter.C2V(respCap)),
                                                                                    BaseTypeAdapter.V2C, BaseTypeAdapter.C2V);
 }
Exemplo n.º 22
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability (capability);

            if(ssc == null)
            {
                ssc = (ScreenScraperCapability)capability;
            }
        }
Exemplo n.º 23
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability(capability);

            if (ssc == null)
            {
                ssc = (ScreenScraperCapability)capability;
            }
        }
Exemplo n.º 24
0
 internal CPhonebooks(CItem parent, ICapability medCapability) : base(parent)
 {
     if (!(parent is CSource))
     {
         throw new Exception("Internal error");
     }
     this.MedCapability = medCapability;
     this.Update();
 }
Exemplo n.º 25
0
        public override bool RemoveCapability(ICapability capability)
        {
            bool ret = base.RemoveCapability(capability);

            fileTransferCapability = null;
            this.Close();

            return(ret);
        }
Exemplo n.º 26
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability(capability);

            if (wmf == null)
            {
                wmf = (WMFileCapability)capability;
            }
        }
Exemplo n.º 27
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability(capability);

            if (fileTransferCapability == null)
            {
                fileTransferCapability = (FileTransferCapability)capability;
            }
        }
Exemplo n.º 28
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability (capability);

            if(wb == null)
            {
                wb = (WhiteboardCapability)capability;
                wb.ObjectReceived += new CapabilityObjectReceivedEventHandler(OnObjectReceived);
            }
        }
        public void Add(ICapability capability)
        {
            var valueType = capability.GetType();

            if (_supports.TryGetValue(valueType, out _))
            {
                _supports.Remove(valueType);
            }
            _supports.Add(valueType, capability);
        }
Exemplo n.º 30
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability(capability);

            if (wb == null)
            {
                wb = (WhiteboardCapability)capability;
                wb.ObjectReceived += new CapabilityObjectReceivedEventHandler(OnObjectReceived);
            }
        }
Exemplo n.º 31
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability(capability);

            if (fileTransferCapability == null)
            {
                fileTransferCapability = (FileTransferCapability)capability;
                fileTransferCapability.ObjectReceived +=
                    new CapabilityObjectReceivedEventHandler(ObjectReceived);
            }
        }
Exemplo n.º 32
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability (capability);

            if (fileTransferCapability == null)
            {
                fileTransferCapability = (FileTransferCapability)capability;
                fileTransferCapability.ObjectReceived += 
                    new CapabilityObjectReceivedEventHandler(ObjectReceived);
            }
        }
Exemplo n.º 33
0
 public void Init(Stream readStream, Stream writeStream, ICapability bootstrapCapability)
 {
     _msgStream  = new MessageStream();
     _segFactory = new ArrayPoolSegmentFactory();
     _msgStream.Init(readStream, writeStream, _segFactory);
     _ctSource      = new CancellationTokenSource();
     _exceptions    = new ConcurrentQueue <System.Exception>();
     _exports       = new ExportTable <Export>();
     _bootstrapCap  = bootstrapCapability;
     _capToExportId = new Dictionary <ICapability, uint>();
 }
Exemplo n.º 34
0
        public virtual void ExecuteCommand(ICapability capability, Command command)
        {
            if (capability == null || command == null)
            {
                return;
            }

            command.Execute(capability);

            OnCommandExecuted?.Invoke(capability, command);
            EventManager.UnitCommandExecuted(this, capability, command);
        }
Exemplo n.º 35
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability (capability);

            if(chatCapability == null)
            {
                chatCapability = (ChatCapability)capability;

                // Hook the ObjectReceived event so we can receive incoming data
                chatCapability.ObjectReceived += new CapabilityObjectReceivedEventHandler(objectReceived);
            }
        }
Exemplo n.º 36
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability(capability);

            if (rtChat == null)
            {
                rtChat = (RichTextChatCapability)capability;

                // Hook the ObjectReceived event so we can receive incoming data
                rtChat.ObjectReceived += new CapabilityObjectReceivedEventHandler(OnObjectReceived);
            }
        }
Exemplo n.º 37
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability (capability);

            if(rtChat == null)
            {
                rtChat = (RichTextChatCapability)capability;

                // Hook the ObjectReceived event so we can receive incoming data
                rtChat.ObjectReceived += new CapabilityObjectReceivedEventHandler(OnObjectReceived);
            }
        }
Exemplo n.º 38
0
        public override void AddCapability(ICapability capability)
        {
            base.AddCapability(capability);

            if (chatCapability == null)
            {
                chatCapability = (ChatCapability)capability;

                // Hook the ObjectReceived event so we can receive incoming data
                chatCapability.ObjectReceived += new CapabilityObjectReceivedEventHandler(objectReceived);
            }
        }
Exemplo n.º 39
0
        public override bool RemoveCapability(ICapability capability)
        {
            bool ret = base.RemoveCapability (capability);

            if (ret)
            {
                fileTransferCapability.ObjectReceived -= 
                    new CapabilityObjectReceivedEventHandler(ObjectReceived);
                fileTransferCapability = null;
            }

            return ret;
        }
Exemplo n.º 40
0
        /// <summary>
        /// Add a capability object to the form
        /// 
        /// Override this method in order to do something special with the capability being added
        /// </summary>
        /// <param name="capability">The capability object to add</param>
        public virtual void AddCapability(ICapability capability)
        {
            // TODO: add validations "contains"

            listCapabilities.Add(capability);

            #region Diagnostics
            #if SFHashTableDiagnostics
                Trace.WriteLine("    SharedForm.AddCapability " + capability.GetType());
                Trace.WriteLine("    new count after add: listCapabilities.Count: " + listCapabilities.Count);
            #endif
            #endregion Diagnostics
        }
Exemplo n.º 41
0
        public override bool RemoveCapability(ICapability capability)
        {
            bool ret = base.RemoveCapability (capability);

            if(ret)
            {
                // Remove the ObjectReceived event handler.
                // This form is going away, but the Capability may be replayed in which case we'd receive this event into a disposed form!
                rtChat.ObjectReceived -= new CapabilityObjectReceivedEventHandler(OnObjectReceived);
                rtChat = null;
            }

            return ret;
        }
Exemplo n.º 42
0
        public override bool RemoveCapability(ICapability capability)
        {
            bool ret = base.RemoveCapability (capability);

            if(ret)
            {
                ssc = null;

                fgm.Stop();
                FilterGraph.RemoveAllFilters(fgm);
                fgm = null;
            }

            return ret;
        }
Exemplo n.º 43
0
        internal static VCapability C2V(ICapability contract)
        {
            if (contract == null)
                return null;

            if (!System.Runtime.Remoting.RemotingServices.IsObjectOutOfAppDomain(contract) &&
                (contract.GetType().Equals(typeof(CapabilityV2C))))
            {
                return ((CapabilityV2C)(contract)).GetSourceView();
            }
            else
            {
                return new CapabilityC2V(contract);
            }
        }
Exemplo n.º 44
0
        public override void AddCapability(ICapability capability)
        {
            // Load the saved options
            string path = Application.UserAppDataPath + "\\OneNote Importer\\options.dat";
            if( File.Exists(path) )
            {
                FileStream fs = new FileStream(path, FileMode.Open);
                BinaryFormatter bf = new BinaryFormatter();
                authorToFolderHash = (Hashtable) bf.Deserialize(fs);
                fs.Close();
            }
            else // create default options
            {
                this.authorToFolderHash = new Hashtable();
            }

            // Hook the closing event so we can write the options back to the registry
            this.Closing += new CancelEventHandler(OptionsForm_Closing);

            // Resource manager...
            System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
            string resName = asm.FullName.Substring(0, asm.FullName.IndexOf(',')) + ".sysTray.ico";
            System.IO.Stream s = asm.GetManifestResourceStream(resName);

            // Create the SysTray icon
            sysTrayIcon = new NotifyIcon();
            sysTrayIcon.Icon = new Icon(s);
            sysTrayIcon.Visible = true;
            sysTrayIcon.Text = "OneNote Importer";
            sysTrayIcon.DoubleClick +=new EventHandler(sysTrayIcon_DoubleClick);

            // Create the ContextMenu for the SysTray Icon
            ContextMenu sysTrayMenu = new ContextMenu(
                new MenuItem[]{
                                  new MenuItem( "Sync to Instructor", new EventHandler(SyncSlide) ),
                                  new MenuItem( "Stay Auto-sync'd", new EventHandler(AutoSync) )
                              } );
            sysTrayMenu.MenuItems[1].Checked = this.AutoSyncSlides;
            sysTrayIcon.ContextMenu = sysTrayMenu;

            // This is truly un-graceful code, but this form doesn't exist
            //  at instantiation of the Capability, so we have to hook the event
            //  in a very backwards fashion
            this.SyncCurrentSlide += new EventHandler(((PresentationToOneNoteCapability)capability).SyncToPage);

            // Through a little slight of hand, the form is never seen...
            this.VisibleChanged += new EventHandler(ThisFormDoesNotExist_VisibleChanged);
        }
Exemplo n.º 45
0
        /// <summary>
        /// Remove a capability object from the form
        /// 
        /// Override this method in order to do something special with the capability being removed
        /// </summary>
        /// <param name="capability">The capability object to remove</param>
        /// <returns>true if there are no more instances of this capability</returns>
        public virtual bool RemoveCapability(ICapability capability)
        {
            // TODO: add validations "contains"

            listCapabilities.Remove(capability);

            #region Diagnostics
#if SFHashTableDiagnostics
                Trace.WriteLine("    SharedForm.RemoveCapability " + capability.GetType());
                Trace.WriteLine("    new count after remove: listCapabilities.Count: " 
                    + listCapabilities.Count);
#endif
            #endregion Diagnostics

            return !listCapabilities.Contains(capability);
        }
Exemplo n.º 46
0
        private void InitAudioCapability(ICapability capability)
        {
            if (audioCapability == null)
            {
                audioCapability = (AudioCapability)capability;

                // We want always to have the name of the video capability
                // if the form is shared with a video capability
                // => If the audio capability come after the video capability,
                // we want to overwrite with the name of the video capability.
                if (videoCapability != null)
                {
                    this.Text = videoCapability.Name;
                }

                // TODO: Add a condition to not call InitVideoUI() if isFormLoaded is false to prevent
                // the form to show to early
                InitAudioUI();

                // Set the UI borders so the audio capability can calculate the
                // AV form size given some constrains due to the video ratio
                audioCapability.UIBorderWidth = UIBorderWidth;
                audioCapability.UIBorderHeight = UIBorderHeight;
            }
        }
Exemplo n.º 47
0
        private void InitVideoCapability(ICapability capability)
        {
            if (videoCapability == null)
            {
                videoCapability = (VideoCapability)capability;

                this.Text = videoCapability.Name;

                // Unintuitively causes us to look at the vidSrcRatio and use it if it's been set
                TrimBlackFromVideo(base.Size);

                // TODO: Add a condition to not call InitVideoUI() if isFormLoaded is false to prevent
                // the form to show to early
                InitVideoUI();

                videoCapability.VideoWindowHandle = pbVideo.Handle;
                videoCapability.ResizeVideoStream(pbVideo.Height, pbVideo.Width);

                // Set the UI borders so the video capability can calculate the
                // AV form size given some constrains due to the video ratio
                videoCapability.UIBorderWidth = UIBorderWidth;
                videoCapability.UIBorderHeight = UIBorderHeight;
            }
        }
Exemplo n.º 48
0
        public void SetRestrictions(ICapability cap)
        {
            bool bExtended = Array.IndexOf(cap.GetArrayCapability(CapabilityType.FdoCapabilityType_CommandList), OSGeo.FDO.Commands.CommandType.CommandType_ExtendedSelect) >= 0;

            if (!cap.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSelectOrdering) && !bExtended)
                tabQueryOptions.TabPages.Remove(TAB_ORDERING);

            if (!cap.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsJoins))
                tabQueryOptions.TabPages.Remove(TAB_JOINS);
        }
Exemplo n.º 49
0
 public void AsyncReturn(string roleName, string opName, IListContract<IParamType> retVals, IPort p, ICapability respCap)
 {
     _view.AsyncReturn(roleName, opName,
                       CollectionAdapters.ToIList<IParamType, VParamType>(retVals, BaseTypeAdapter.C2V, BaseTypeAdapter.V2C),
                       PortAdapter.C2V(p), CapabilityAdapter.C2V(respCap));
 }
Exemplo n.º 50
0
 public bool Unsubscribe(string roleName, string opName, IPort fromPort, ICapability respCap)
 {
     return _view.Unsubscribe(roleName, opName, PortAdapter.C2V(fromPort), CapabilityAdapter.C2V(respCap));
 }
Exemplo n.º 51
0
        private static void autoPositionCV(ICapability cv)
        {
            Debug.Assert(Conference.ActiveVenue != null);

            // Assume a standalone capability, override if shared forms are used
            Guid id = cv.UsesSharedForm ? cv.SharedFormID : cv.ID;

            // Only auto-position ourselves once
            if(!capabilityForms.Contains(id))
            {
                if (cv is ICapabilityWindow)
                {
                    ICapabilityWindow iCW = (ICapabilityWindow)cv;

                    // The CapabilityWindow is not initialized or we don't want to auto-position
                    if (iCW.Height == 0 || autoPosition == AutoPositionMode.None)
                    {
                        return;
                    }

                    // Set bottom and right
                    if (iCW is ICapabilityWindowAutoSize)
                    {
                        autoSizeCapabilityWindow(iCW);
                    }

                    bool foundOpenPosition = false;

                    int workingTop = SystemInformation.WorkingArea.Top;
                    int workingLeft = SystemInformation.WorkingArea.Left;
                    int workingBottom = SystemInformation.WorkingArea.Bottom;
                    int workingRight = SystemInformation.WorkingArea.Right;

                    Rectangle rect = new Rectangle(workingLeft, workingTop, iCW.Width, iCW.Height);
                    int minY = rect.Top + rect.Height; // Assume we want to move down the height of the capability

                    while (!foundOpenPosition)
                    {
                        // Check for horizontal overflow, if so go down a column
                        if (rect.Left + rect.Width > workingRight)
                        {
                            rect = new Rectangle(workingLeft, minY, rect.Width, rect.Height);
                            minY = rect.Top + rect.Height;
                        }

                        // Check for verical overflow, if so go back to the upper left
                        if (rect.Top + rect.Height > workingBottom)
                        {
                            rect = new Rectangle(workingLeft, workingTop, rect.Width, rect.Height);
                            break; // force position, even if overlapping existing capability
                        }

                        // Assume we found an open position, and prove it overlaps an existing one
                        foundOpenPosition = true;

                        // Check for window already present
                        foreach(ICapability ic in capabilities.Values)
                        {
                            Guid icID = ic.UsesSharedForm ? ic.SharedFormID : ic.ID;

                            // Skip me (don't try to check against self)
                            if (icID != id && ic is ICapabilityWindow)
                            {
                                // This is incorrect information - the form may have been moved by user - jasonv 10/13/2004
                                Rectangle icRect = ((ICapabilityWindow)ic).Rectangle;

                                if (rect.IntersectsWith(icRect))
                                {
                                    // Next horizontal position to try
                                    rect = new Rectangle(icRect.Left + icRect.Width, rect.Top, rect.Width, rect.Height);

                                    // Next vertical position to try (in event of horizontal overflow)
                                    if(icRect.Top + icRect.Height < minY)
                                    {
                                        minY = icRect.Top + icRect.Height;
                                    }

                                    foundOpenPosition = false;
                                    break;
                                }
                            }
                        }
                    }

                    iCW.Top = rect.Top;
                    iCW.Left = rect.Left;

                    capabilityForms.Add(id);
                }
            }
        }
Exemplo n.º 52
0
        public override void AddCapability(ICapability capability) {
            base.AddCapability(capability);

            if (m_Capability == null) {
                m_Capability = (PresenterCapability)capability;

                // Hook the ObjectReceived event so we can receive incoming data
                m_Capability.ObjectReceived += new CapabilityObjectReceivedEventHandler(objectReceived);

                //Set the role to instructor if we initiated the capability.
                if (m_Capability.IsSender) {
                    //Set the instructor role
                    InstructorModel instructor = new InstructorModel(Guid.NewGuid());
                    using (Synchronizer.Lock(this.m_Model.Participant.SyncRoot)) {
                        m_Model.Participant.Role = instructor;
                    }
                    using (Synchronizer.Lock(this.m_Model.ViewerState.SyncRoot)) {
                        this.m_Model.ViewerState.iRole = 2;
                    }
                    //We also need to set up a couple of other things to make the instructor functional:  A network association
                    // and an empty presentation.
                    PresentationModel pres = new PresentationModel(Guid.NewGuid(), m_Model.Participant, "Untitled Presentation", true);
                    using (Synchronizer.Lock(m_Model.Network.SyncRoot)) {
                        m_Model.Network.Association = m_Model.Participant;
                    }
                    using (Synchronizer.Lock(instructor.SyncRoot)) {
                        instructor.CurrentPresentation = pres;
                    }
                }
                else { 
                    //Set student role
                    using (Synchronizer.Lock(this.m_Model.Participant.SyncRoot)) {
                        m_Model.Participant.Role = new StudentModel(Guid.NewGuid());
                    }
                    using (Synchronizer.Lock(this.m_Model.ViewerState.SyncRoot)) {
                        this.m_Model.ViewerState.iRole = 1;
                    }
                }

                //Before we create the CXPCapabilityMessageSender, we want to wait until the Play and Send methods have completed.
                //Otherwise we can end up trying to send before the capability is ready to accept messages.
                bool createCapabilitySenderNow = false;
                lock (m_Capability) { //This section synchronized with the PresenterCapability instance.
                    if (m_Capability.IsPlayingAndSending) {
                        createCapabilitySenderNow = true;
                    }
                    else {
                        m_Capability.OnPlay += new PresenterCapability.OnPlayHandler(OnCapabilityPlay);
                    }
                }
                if (createCapabilitySenderNow) {
                    m_CapabilitySender = new CXPCapabilityMessageSender(m_Model, m_Capability);
                }
            }
        }
Exemplo n.º 53
0
        public static void RaiseCapabilityStoppedSending(ICapability capability)
        {
            try
            {
                if (CapabilityStoppedSending != null)
                {
                    FormInvoke(CapabilityStoppedSending, new object[] { null, new CapabilityEventArgs(capability) } );
                }

                if (logActivity == true)
                {
                    eventLog.WriteEntry("Stopped Sending " + capability.ToString(), EventLogEntryType.Information, 6);
                }
            }
            catch (ThreadAbortException) {}
            catch (Exception e)
            {
                eventLog.WriteEntry(e.ToString(), EventLogEntryType.Error, 99);
            }
        }
Exemplo n.º 54
0
 public CapabilityC2V(ICapability contract)
 {
     _contract = contract;
     _handle = new ContractHandle(contract);
 }
Exemplo n.º 55
0
        private static void RaiseCapabilityRemoved(ICapability capability)
        {
            try
            {
                if (CapabilityRemoved != null)
                {
                    FormInvoke(CapabilityRemoved, new object[] { null, new CapabilityEventArgs(capability) } );
                }

                if (logActivity == true)
                {
                    eventLog.WriteEntry("Removed " + capability.ToString(), EventLogEntryType.Information, 5);
                }
            }
            catch (ThreadAbortException) {}
            catch (Exception e)
            {
                eventLog.WriteEntry(e.ToString() ,EventLogEntryType.Error, 99);
            }
        }
Exemplo n.º 56
0
        private static void RaiseCapabilityParticipantRemoved(ICapability capability, IParticipant participant)
        {
            try
            {
                if (CapabilityParticipantRemoved != null)
                {
                    FormInvoke(CapabilityParticipantRemoved, new object[] { capability, new ParticipantEventArgs(participant) } );
                }

                if (logActivity == true)
                {
                    eventLog.WriteEntry("CapabilityParticipantRemoved " + capability.ToString() + ":" + participant.ToString(), EventLogEntryType.Information, 1);
                }
            }
            catch (ThreadAbortException) {}
            catch (Exception e)
            {
                eventLog.WriteEntry(e.ToString(),EventLogEntryType.Error, 99);
            }
        }
Exemplo n.º 57
0
        private static void DisposeCapability(ICapability capability)
        {
            // Let the capability clean itself up
            capability.Dispose();

            // Now we'll clean up our state
            Guid id = capability.ID;

            // Make sure this Capability is removed from the CapabilitySenders
            if (Conference.capabilitySenders.ContainsKey(id))
            {
                Conference.capabilitySenders.Remove(id);
            }

            // Make sure this Capability is removed from the CapabilityViewers
            if (Conference.capabilityViewers.ContainsKey(id))
            {
                Conference.capabilityViewers.Remove(id);
            }

            // Remove from the main collection
            Debug.Assert(capabilities.ContainsKey(id));
            Conference.capabilities.Remove(id);

            Conference.RaiseCapabilityRemoved(capability);
        }
Exemplo n.º 58
0
        public void SetRestrictions(ICapability cap)
        {
            if (!cap.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSelectOrdering))
                tabQueryOptions.TabPages.Remove(TAB_ORDERING);

            if (!cap.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsJoins))
                tabQueryOptions.TabPages.Remove(TAB_JOINS);
        }
Exemplo n.º 59
0
        public static void RaiseCapabilityPlaying(ICapability capability)
        {
            try
            {
                if (CapabilityPlaying != null)
                {
                    FormInvoke(CapabilityPlaying, new object[] { null, new CapabilityEventArgs(capability) } );
                }

                if (capability is ICapabilityWindow)
                {
                    autoPositionCV(capability);
                }

                if (logActivity)
                {
                    eventLog.WriteEntry("Playing " + capability.ToString(), EventLogEntryType.Information, 4);
                }
            }
            catch (ThreadAbortException) {}
            catch (Exception e)
            {
                eventLog.WriteEntry(e.ToString() ,EventLogEntryType.Error, 99);
            }
        }
Exemplo n.º 60
0
        public void SetRestrictions(ICapability cap)
        {
            if (!cap.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSelectOrdering))
                tabQueryOptions.TabPages.Remove(TAB_ORDERING);

            if (!cap.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSelectGrouping))
                tabQueryOptions.TabPages.Remove(TAB_GROUPING);

            if (!cap.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsSelectDistinct))
                chkDistinct.Enabled = false;

            if (!cap.GetBooleanCapability(CapabilityType.FdoCapabilityType_SupportsJoins))
                tabQueryOptions.TabPages.Remove(TAB_JOINS);
        }