Exemplo n.º 1
0
        public RandomNetworkGenElement Create(Guid id, IElementDefinition defType)
        {
            RandomNetworkGenElement el = new RandomNetworkGenElement(id, defType);

            IInputPortMgr inPortMgr = CreateInputPortMgr(el);
            IOutputPortMgr outPortMgr = CreateOutputPortMgr(el);

            el.InPortMgr = inPortMgr;
            el.OutPortMgr = outPortMgr;

            IRandomNetGenParamMgr paramMgr = CreateParamMgr();
            el.ParamMgr = paramMgr;

            Guid fxId = Guid.NewGuid();
            IRandomNetworkGenFx fx = CreateMyFx(fxId, id);
            el.Fx = fx;

            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                ISimpleSettingsMgr settingsMgr = fac.CreateSettingsMgr(el);
                el.SettingsMgr = settingsMgr;
            }

            using (OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                ISimpleOptionsMgr optsMgr = fac.CreateOptionsMgr(el);
                el.OptionsMgr = optsMgr;
            }

            return el;
        }
Exemplo n.º 2
0
        public ICompoundElementView CreateCompoundView(IElementDefinition definition)
        {
            throw new NotImplementedException("The method or operation is not implemented.");//TODO
            //try
            //{
            //    // just create the view,
            //    if (definition != null)
            //    {
            //        IElementTemplateDictionary dic = Base.ProviderContainer.CoreContainer.Resolve<IElementTemplateDictionary>();
            //        IElementTemplate template = dic[definition.ElementTypeId];

            //        CompoundGoElement el = new CompoundGoElement();
            //        el.Caption = definition.Caption;
            //        el.ToolTipTitle = definition.Caption;
            //        el.ToolTipText = definition.ElementDescription;
            //        SetImages(el, template);

            //        el.InitializeDisplay();
            //        CreatePorts(el, definition.InputPortTypes, definition.OutputPortTypes);
            //        return el;
            //    }
            //}
            //catch (Exception ex)
            //{
            //    string x = ex.Message;
            //}
            //finally
            //{

            //}

            //return null;
        }
Exemplo n.º 3
0
 public ElementTemplate(IElementDefinition definition, Image largeImage, Image mediumImage, Image smallImage)
 {
     Definition = definition;
     LargeImage = largeImage;
     MediumImage = mediumImage;
     SmallImage = smallImage;
 }
Exemplo n.º 4
0
        public ExtractKthCoreElement Create(IElementTicket ticket, IElementDefinition defType)
        {
            if (ticket.TypeId != defType.ElementTypeId)
            {
                throw new InvalidOperationException(Properties.Resources.MssgTicketTypeIdDoesNotMatchDefTypeIdFormat(ticket.TypeId, defType.ElementTypeId));
            }

            ExtractKthCoreElement el = new ExtractKthCoreElement(ticket.ElementId, defType);

            IInputPortMgr inPortMgr = CreateInputPortMgr(el, ticket.InputPortMgrId, ticket.InputPortIds[0]);
            IOutputPortMgr outPortMgr = CreateOutputPortMgr(el, ticket.OutputPortMgrId, ticket.OutputPortIds[0]);

            el.InPortMgr = inPortMgr;
            el.OutPortMgr = outPortMgr;

            IExtractKthCoreParamMgr paramMgr = CreateParamMgr(ticket.ParamMgrId);
            el.ParamMgr = paramMgr;

            IExtractKthCoreFx fx = CreateMyFx(ticket.FxId, ticket.ElementId);
            el.Fx = fx;

            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                ISimpleSettingsMgr settingsMgr = fac.CreateSettingsMgr(el);
                el.SettingsMgr = settingsMgr;
            }

            using (OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                ISimpleOptionsMgr optsMgr = fac.CreateOptionsMgr(el);
                el.OptionsMgr = optsMgr;
            }

            return el;
        }
Exemplo n.º 5
0
        public ExtractKthCoreElement Create(Guid elementId, IElementDefinition defType)
        {
            ExtractKthCoreElement el = new ExtractKthCoreElement(elementId, defType);

            IInputPortMgr inPortMgr = CreateInputPortMgr(el);
            IOutputPortMgr outPortMgr = CreateOutputPortMgr(el);

            el.InPortMgr = inPortMgr;
            el.OutPortMgr = outPortMgr;

            IExtractKthCoreParamMgr paramMgr = CreateParamMgr();
            el.ParamMgr = paramMgr;

            Guid fxId = Guid.NewGuid();
            IExtractKthCoreFx fx = CreateMyFx(fxId, elementId);
            el.Fx = fx;

            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                ISimpleSettingsMgr settingsMgr = fac.CreateSettingsMgr(el);
                el.SettingsMgr = settingsMgr;
            }

            using (OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                ISimpleOptionsMgr optsMgr = fac.CreateOptionsMgr(el);
                el.OptionsMgr = optsMgr;
            }

            return el;
        }
        public static string GetDeclaredModifiers(this IElementDefinition definition)
        {
            definition = definition ?? throw new ArgumentNullException(nameof(definition));

            var modifiers = new List <string>(2);
            var parts     = definition.DeclaredModifiers.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var part in parts)
            {
                switch (part)
                {
                case "private":
                case "internal":
                case "protected":
                case "public":
                    break;

                default:
                    modifiers.Add(part);
                    break;
                }
            }

            return(string.Join(" ", modifiers));
        }
Exemplo n.º 7
0
        public DataPropertiesElement Create(Guid id, IElementDefinition defType)
        {
            DataPropertiesElement el = new DataPropertiesElement(id, defType);

            IInputPortMgr inPortMgr = CreateInputPortMgr(el);
            IOutputPortMgr outPortMgr = CreateOutputPortMgr(el);

            el.InPortMgr = inPortMgr;
            el.OutPortMgr = outPortMgr;

            IDataPropertiesElementParamMgr paramMgr = CreateParamMgr();
            el.ParamMgr = paramMgr;

            Guid fxId = Guid.NewGuid();
            IDataPropertiesElementFx fx = CreateMyFx(fxId, id);
            el.Fx = fx;

            using (SettingsMgrFactory fac = new SettingsMgrFactory())
            {
                ICompoundSettingsMgr settingsMgr = fac.CreateSettingsMgr(el);
                el.SettingsMgr = settingsMgr;
            }

            using (OptionsMgrFactory fac = new OptionsMgrFactory())
            {
                ICompoundOptionsMgr optsMgr = fac.CreateOptionsMgr(el);
                el.OptionsMgr = optsMgr;
            }

            return el;
        }
        public static IReadOnlyCollection <IAttributeDefinition> DetermineAttributes(AccessorDeclarationSyntax node,
                                                                                     IElementDefinition declaringItem)
        {
            node          = node ?? throw new ArgumentNullException(nameof(node));
            declaringItem = declaringItem ?? throw new ArgumentNullException(nameof(declaringItem));

            var attributeList = node.AttributeLists;

            return(DetermineAttributes(declaringItem, attributeList));
        }
Exemplo n.º 9
0
        /// <summary>
        /// This method returns the appropriate <see cref="IElementDefinition"/> which will in turn
        /// create the instance of the ElementCtrlUI (ie the view) for the type of element defined
        /// in the <see cref="IElementViewFactory"/> parameter.
        /// </summary>
        public IElementViewFactory Create(IElementDefinition definition)
        {
            if (_uiConfiguration == "Windows.Forms")
            {
                // all there is right now
                return new ElementViewFactory();
            }

            return null;
        }
Exemplo n.º 10
0
 public ElementTemplate(IElementDefinition definition, Image largeImage, Image mediumImage, Image mediumImageComplete, Image mediumImageError, Image smallImage, Icon mediumIcon, Icon smallIcon)
 {
     Definition = definition;
     LargeImage = largeImage;
     MediumImage = mediumImage;
     MediumImageComplete = mediumImageComplete;
     MediumImageError = mediumImageError;
     SmallImage = smallImage;
     MediumIcon = mediumIcon;
     SmallIcon = smallIcon;
 }
Exemplo n.º 11
0
 public SimpleElementFactoryBase(IElementDefinition definition, Guid elementId, Guid fxId, Guid[] inputPortIds, Guid[] outputPortIds)
 {
     Definition = definition;
     ElementId = elementId;
     InputPortIds = inputPortIds;
     OutputPortIds = outputPortIds;
     FxId = fxId;
     InputPortMgrId = Guid.NewGuid();
     OutputPortMgrId = Guid.NewGuid();
     SettingsMgrId = Guid.NewGuid();
     OptionsMgrId = Guid.NewGuid();
     ParamMgrId = Guid.NewGuid();
 }
Exemplo n.º 12
0
        public IElementFactory Create(IElementDefinition definition)
        {
            // TODO  sucks, hack, dont like
            IElementFactory elFac = null;

            if (definition != null)
            {
                string fullName = string.Format("{0}.{1}", definition.NameSpace, definition.FactoryName);
                Type facType = this.GetType().Assembly.GetType(fullName);

                ConstructorInfo csi = facType.GetConstructor(new Type[] { });
                elFac = csi.Invoke(null) as IElementFactory;
            }

            return elFac;
        }
        public ElementWindow(IElementConfiguration appenderConfiguration,
                             IElementDefinition propertyDefinition,
                             IWindowSizeLocation windowSizeLocation,
                             ISaveStrategy saveStrategy)
            : base(windowSizeLocation.RetentionKey)
        {
            InitializeComponent();
            DataContext        = this;
            mMessageBoxService = new MessageBoxService(this);

            mConfiguration = appenderConfiguration;
            mSaveStrategy  = saveStrategy;
            SetWindowSizeLocation(windowSizeLocation);
            PropertyDefinition = propertyDefinition;
            PropertyDefinition.MessageBoxService = mMessageBoxService;
            Loaded += WindowOnLoaded;
            Icon    = new BitmapImage(new Uri(PropertyDefinition.Icon));
        }
Exemplo n.º 14
0
        public IElementView CreateView(IElementDefinition definition)
        {
            if (definition != null)
            {
                if (definition.Scope == ElementScope.Simple)
                {
                    return CreateSimpleView(definition);
                }
                else if (definition.Scope == ElementScope.Compound)
                {
                    return CreateCompoundView(definition);
                }
                else
                {
                    return CreateProcedureView(definition);
                }
            }

            return null;
        }
Exemplo n.º 15
0
        public ElementWindow(IElementConfiguration appenderConfiguration,
                             IElementDefinition propertyDefinition,
                             IWindowSizeLocation windowSizeLocation,
                             ISaveStrategy saveStrategy)
            : base(windowSizeLocation.RetentionKey)
        {
            InitializeComponent();
            DataContext        = this;
            mMessageBoxService = new MessageBoxService(this);

            mConfiguration     = appenderConfiguration;
            WindowSizeLocation = windowSizeLocation;
            mSaveStrategy      = saveStrategy;
            SetWindowSizeLocation(windowSizeLocation);
            PropertyDefinition = propertyDefinition;
            PropertyDefinition.MessageBoxService = mMessageBoxService;
            Properties = new ObservableCollection <IProperty>();
            Loaded    += WindowOnLoaded;
            ((INotifyCollectionChanged)PropertyDefinition.Properties).CollectionChanged += PropertiesOnCollectionChanged;
            Icon = new BitmapImage(new Uri(PropertyDefinition.Icon));
        }
Exemplo n.º 16
0
        public SimpleElementFactoryBase(IElementDefinition definition)
        {
            Definition = definition;
            ElementId = Guid.NewGuid();
            InputPortMgrId = Guid.NewGuid();
            OutputPortMgrId = Guid.NewGuid();
            SettingsMgrId = Guid.NewGuid();
            OptionsMgrId = Guid.NewGuid();
            ParamMgrId = Guid.NewGuid();
            FxId = Guid.NewGuid();

            InputPortIds = new Guid[Definition.InputPortTypes.Length];
            for (int i = 0; i < InputPortIds.Length; i++)
            {
                InputPortIds[i] = Guid.NewGuid();
            }

            OutputPortIds = new Guid[Definition.OutputPortTypes.Length];
            for (int i = 0; i < OutputPortIds.Length; i++)
            {
                OutputPortIds[i] = Guid.NewGuid();
            }
        }
Exemplo n.º 17
0
        public static bool TryGetResource(this IElementDefinition element, string key, out object value)
        {
            while (element != null)
            {
                if (element is IResourcesProvider ve && ve.IsResourcesCreated && ve.Resources.TryGetValue(key, out value))
                {
                    return(true);
                }
                if (element is Application app && app.SystemResources != null && app.SystemResources.TryGetValue(key, out value))
                {
                    return(true);
                }
                element = element.Parent;
            }

            //Fallback for the XF previewer
            if (Application.Current != null && ((IResourcesProvider)Application.Current).IsResourcesCreated && Application.Current.Resources.TryGetValue(key, out value))
            {
                return(true);
            }

            value = null;
            return(false);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Creates a full MVP instance of an element with <paramref name="element"/> as the model and 
        /// adds the element view to the <see cref="IWorkSpacePresenter"/>.<see cref="View"/> and adds the
        /// element presenter to the <see cref="IWorkSpacePresenter"/>.<see cref="ElementPresenters"/> collection.
        /// </summary>
        /// <param name="element">The <see cref="IElement"/> instance for which an element view and presenter are created.</param>
        /// <remarks>The <paramref name="element"/> already exists in <see cref="WorkSpace"/>.<see cref="ElementsMgr"/>.</remarks>
        internal void LoadElementIntoView(IElement element, IElementDefinition def, PointF location)
        {
            // create the instance of the element view
            IElementView view = CreateElementView(def);
            view.Id = element.Id;

            ISetElementOwnerId setterOwnerId = (view as ISetElementOwnerId);
            setterOwnerId.SetElementOwnerId(element.Id);

            // create the instance of the element presenter with the element and the view
            IElementPresenter presenter = CreateElementPresenter(element, view);

            // add the element to the view.
            if (presenter != null)
            {
                View.Add(view, location);
                ElementPresenters.Add(element.Id, presenter);
            }
        }
Exemplo n.º 19
0
        internal IElementView CreateElementView(IElementDefinition defType)
        {
            IElementView view = null;
            throw new NotImplementedException();
            //IElementViewFactory viewFac = Base.ContainerProvider.CoreContainer.Resolve<IElementViewFactory>();
            //if (viewFac != null)
            //    view = viewFac.CreateView(defType);

            return view;
        }
Exemplo n.º 20
0
        internal IElement CreateElementModel(IElementDefinition defType)
        {
            IElement el = null;
            throw new NotImplementedException();
            //using (IElementFactoryProvider provider = Base.ContainerProvider.PackageContainer.Resolve<IElementFactoryProvider>(defType.PackageName))
            //{
            //    Guid id = GetNewId();

            //    IElementFactory fac = provider.Create(defType);
            //    if (fac != null)
            //        el = fac.CreateElement(id, defType);
            //}

            return el;
        }
Exemplo n.º 21
0
 public Element(IElementDefinition definition, IAttributeBag attributes)
 {
     Attributes = attributes;
     Definition = definition;
 }
Exemplo n.º 22
0
 public ExtractKthCoreElement(Guid id, IElementDefinition defType)
     : base(id, defType)
 {
 }
Exemplo n.º 23
0
 public abstract IElement CreateElement(IElementTicket ticket, IElementDefinition defType);
Exemplo n.º 24
0
 public NetworkPropertiesElement(Guid id, IElementDefinition defType)
     : base(id, defType)
 {
 }
Exemplo n.º 25
0
 public AddElementInstanceEventArgs(IElementDefinition instanceDefType, PointF location)
 {
     Definition = instanceDefType;
     Location = location;
 }
Exemplo n.º 26
0
 protected override string GetDeclaredModifiers(IElementDefinition element)
 {
     return(element.GetDeclaredAccessModifiers());
 }
Exemplo n.º 27
0
 public RandomNetworkGenElement(Guid id, IElementDefinition defType)
     : base(id, defType)
 {
 }
Exemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the MyRoot class.
 /// </summary>
 /// <param name="id">The unique id of this element instance.</param>
 /// <param name="defType">The IElementDefinition of this elements type.</param>
 public CompoundElementBase(Guid id, IElementDefinition defType)
     : this(id)
 {
     TypeId = defType.ElementTypeId;
     TypeName = defType.ElementName;
 }
Exemplo n.º 29
0
 public ElementTemplate(IElementDefinition definition)
 {
     Definition = definition;
 }
Exemplo n.º 30
0
 public abstract ISimpleElement CreateSimpleElement(Guid id, IElementDefinition defType);
Exemplo n.º 31
0
 public IElement CreateElement(IElementTicket ticket, IElementDefinition defType)
 {
     return Create(ticket, defType);
 }
        private static IReadOnlyCollection <IAttributeDefinition> DetermineAttributes(IElementDefinition declaringItem,
                                                                                      SyntaxList <AttributeListSyntax> attributeList)
        {
            var definitions = new List <IAttributeDefinition>();

            foreach (var list in attributeList)
            {
                foreach (var attribute in list.Attributes)
                {
                    var definition = new AttributeDefinition(attribute);

                    definitions.Add(definition);
                }
            }

            return(definitions.AsReadOnly());
        }
Exemplo n.º 33
0
 public IElementFactory Create(IElementDefinition definition)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 34
0
 public ImportNetworkElement(Guid id, IElementDefinition defType)
     : base(id, defType)
 {
 }
Exemplo n.º 35
0
        public static IEnumerable <KeyValuePair <string, object> > GetMergedResources(this IElementDefinition element)
        {
            Dictionary <string, object> resources = null;

            while (element != null)
            {
                var ve = element as IResourcesProvider;
                if (ve != null && ve.IsResourcesCreated)
                {
                    resources = resources ?? new Dictionary <string, object>();
                    foreach (KeyValuePair <string, object> res in ve.Resources.MergedResources)
                    {
                        // If a MergedDictionary value is overridden for a DynamicResource,
                        // it comes out later in the enumeration of MergedResources
                        // TryGetValue ensures we pull the up-to-date value for the key
                        if (!resources.ContainsKey(res.Key) && ve.Resources.TryGetValue(res.Key, out object value))
                        {
                            resources.Add(res.Key, value);
                        }
                        else if (res.Key.StartsWith(Style.StyleClassPrefix, StringComparison.Ordinal))
                        {
                            var mergedClassStyles = new List <Style>(resources[res.Key] as List <Style>);
                            mergedClassStyles.AddRange(res.Value as List <Style>);
                            resources[res.Key] = mergedClassStyles;
                        }
                    }
                }
                var app = element as Application;
                if (app != null && app.SystemResources != null)
                {
                    resources = resources ?? new Dictionary <string, object>(8);
                    foreach (KeyValuePair <string, object> res in app.SystemResources)
                    {
                        if (!resources.ContainsKey(res.Key))
                        {
                            resources.Add(res.Key, res.Value);
                        }
                        else if (res.Key.StartsWith(Style.StyleClassPrefix, StringComparison.Ordinal))
                        {
                            var mergedClassStyles = new List <Style>(resources[res.Key] as List <Style>);
                            mergedClassStyles.AddRange(res.Value as List <Style>);
                            resources[res.Key] = mergedClassStyles;
                        }
                    }
                }
                element = element.Parent;
            }
            return(resources);
        }
 protected abstract string GetDeclaredModifiers(IElementDefinition element);
Exemplo n.º 37
0
        /// <summary>
        /// Creates a full MVP instance of an element as defined by the <paramref name="definition"/> and adds it to
        /// the workspace view and model.
        /// </summary>
        /// <param name="definition">The instance type to add to the workspace.</param>
        public void AddElementInstance(IElementDefinition definition, PointF location)
        {
            // create the instance of the element
            IElement el = CreateElementModel(definition);

            // create the instance of the element view
            IElementView view = CreateElementView(definition);
            view.Id = el.Id;
            ISetElementOwnerId setterOwnerId = (view as ISetElementOwnerId);
            setterOwnerId.SetElementOwnerId(el.Id);

            // create the instance of the element presenter with the element and the view
            IElementPresenter presenter = CreateElementPresenter(el, view);

            // add the element to the workspace.ElementMgr and the view to the workspace view
            if (presenter != null)
            {
                View.Add(view, location);
                WorkSpace.ElementsMgr.Add(el);
                ElementPresenters.Add(el.Id, presenter);
                UpdateElementLocation(el, location);
            }
        }
Exemplo n.º 38
0
 public IElement CreateElement(Guid id, IElementDefinition defType)
 {
     return Create(id, defType);
 }
Exemplo n.º 39
0
        public IElementPresenter AddElementInstance(IElementDefinition definition, IElementView view)
        {
            // create the instance of the element
            IElement el = CreateElementModel(definition);

            // create the instance of the element presenter with the element and the view
            IElementPresenter presenter = CreateElementPresenter(el, view);

            // add the element to the workspace.ElementMgr and the view to the workspace view
            if (presenter != null)
            {
                ElementPresenters.Add(el.Id, presenter);
                WorkSpace.ElementsMgr.Add(el);
                UpdateElementLocation(el, view.Location);
            }
            return presenter;
        }
Exemplo n.º 40
0
 public IProcedureView CreateProcedureView(IElementDefinition definition)
 {
     throw new NotImplementedException("The method or operation is not implemented.");
 }
Exemplo n.º 41
0
 public Element(IElementDefinition definition) : this()
 {
     Definition = definition;
 }