Esempio n. 1
0
 public MenuProperties(string[] items, double fontSize = 42, bool[] enabledItems = null, string[] header = null, double headerSize = 24, bool allowEsc = false, bool allowPlayerInvite = false, int selectedIndex = 0, double width = Double.NaN, double height = Double.NaN)
 {
     Items        = items;
     FontSize     = fontSize;
     EnabledItems = enabledItems ?? Enumerable.Repeat(true, items.Length).ToArray();
     if (EnabledItems.Length != items.Length)
     {
         throw new Exception("Array lengths do not match");
     }
     if (!EnabledItems.Where(o => o == true).Any())
     {
         throw new Exception("All options cannot be disabled");
     }
     Header            = header ?? new string[0];
     HeaderSize        = headerSize;
     AllowEsc          = allowEsc;
     AllowPlayerInvite = allowPlayerInvite;
     SelectedIndex     = selectedIndex;
     Width             = width;
     Height            = height;
     CalculatedHeight  = Double.NaN;
     HeaderLineHeight  = Double.NaN;
     ItemLineHeight    = Double.NaN;
     while (!EnabledItems[SelectedIndex])
     {
         IncrementSelection();
     }
 }
Esempio n. 2
0
        private void ItemOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            var item = sender as CheckedListItem <EventTypeModel>;

            if (item != null && item.IsChecked)
            {
                EnabledItems.Add(item.Item.EventType.Name);
            }
            else if (item != null)
            {
                EnabledItems.Remove(item.Item.EventType.Name);
            }
            UpdateCalenderDataRange(_allEvents, StartDate, EndDate);
        }
Esempio n. 3
0
 public CommandBarManager()
 {
     EnabledItems.Add(AppBarItemType.Command, new SortedSet <AppBarItem>());
     EnabledItems.Add(AppBarItemType.Hidden, new SortedSet <AppBarItem>());
     EnabledItems.Add(AppBarItemType.DeviceDependent, new SortedSet <AppBarItem>());
 }
Esempio n. 4
0
 public CommandBarManager()
 {
     EnabledItems.Add(AppBarItemType.WithIcon, new SortedSet <AppBarItem>());
     EnabledItems.Add(AppBarItemType.OnlyText, new SortedSet <AppBarItem>());
 }
Esempio n. 5
0
 public void UpdateCalenderDataRange(List <EventModel> allEvents, DateTime startDate, DateTime endDate)
 {
     if (EnabledItems.Count > 0)
     {
         Events = new ObservableCollection <EventModel>(allEvents.Where(x => x.Date >= startDate.Date && x.Date <= endDate.Date && EnabledItems.Contains(x.EventType.Name)).OrderBy(x => x.Date));
     }
     else
     {
         Events = new ObservableCollection <EventModel>();
     }
 }
        /// <summary>
        /// Executes the workflow activity.
        /// </summary>
        /// <param name="executionContext">The execution context.</param>
        protected override void Execute(CodeActivityContext executionContext)
        {
            // Create the tracing service
            ITracingService tracingService = executionContext.GetExtension <ITracingService>();

            if (tracingService == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
            }

            tracingService.Trace("Entered CreateConfigXml.Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
                                 executionContext.ActivityInstanceId,
                                 executionContext.WorkflowInstanceId);

            // Create the context
            IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>();

            if (context == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
            }

            tracingService.Trace("CreateConfigXml.Execute(), Correlation Id: {0}, Initiating User: {1}",
                                 context.CorrelationId,
                                 context.InitiatingUserId);

            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                ConfigWRExists.Set(executionContext, true);
                string           ns            = Namespace.Get(executionContext);
                bool             traceEnable   = EnableTrace.Get(executionContext);
                XDocument        xDoc          = null;
                Guid             webresourceId = Guid.Empty;
                QueryByAttribute query         = new QueryByAttribute("webresource");
                query.AddAttributeValue("name", XML_WEBRESOURCE);
                query.AddAttributeValue("webresourcetype", 4);
                query.ColumnSet = new ColumnSet("name", "content");
                EntityCollection ec = service.RetrieveMultiple(query);

                #region Create or Update existing XML WebResource

                if (ec == null || ec.Entities.Count == 0)
                {
                    ConfigWRExists.Set(executionContext, false);
                    if (CreateConfigWR.Get(executionContext))
                    {
                        #region
                        xDoc = RetrieveEntityMetadata(service, ns: ns, traceEnable: traceEnable);
                        Entity xmlWebResource = new Entity("webresource");
                        xmlWebResource["name"]            = XML_WEBRESOURCE;
                        xmlWebResource["displayname"]     = "GenericHierarchyRollupXml.xml";
                        xmlWebResource["content"]         = Convert.ToBase64String(UnicodeEncoding.UTF8.GetBytes(xDoc.ToString()));
                        xmlWebResource["webresourcetype"] = new OptionSetValue(4);
                        webresourceId = service.Create(xmlWebResource);
                        ec.Entities.Add(xmlWebResource);
                        PublishWebResource(webresourceId, service);
                        #endregion
                    }
                }
                else if (RefreshConfig.Get <bool>(executionContext))
                {
                    #region
                    xDoc = RetrieveEntityMetadata(service, ns: ns, traceEnable: traceEnable);
                    bool      webResourceChanged = false;
                    byte[]    binary             = Convert.FromBase64String(ec.Entities[0].Attributes["content"].ToString());
                    XDocument xDocExisting       = XDocument.Parse(UnicodeEncoding.UTF8.GetString(binary));

                    foreach (XElement xe in xDoc.Root.Elements("entity"))
                    {
                        if (xDocExisting.Root.Elements("entity").Where(a => a.Attribute("ReferencingEntity").Value == xe.Attribute("ReferencingEntity").Value&& a.Attribute("ReferencingAttribute").Value == xe.Attribute("ReferencingAttribute").Value&& a.Attribute("ReferencedEntity").Value == xe.Attribute("ReferencedEntity").Value).Count() == 0)
                        {
                            xDocExisting.Root.Add(xe);
                            webResourceChanged = true;
                        }
                    }

                    if (webResourceChanged)
                    {
                        ec.Entities[0].Attributes["content"] = Convert.ToBase64String(UnicodeEncoding.UTF8.GetBytes(xDocExisting.ToString()));
                        service.Update(ec.Entities[0]);
                        PublishWebResource(ec.Entities[0].Id, service);
                    }
                    #endregion
                }
                #endregion

                if (!string.IsNullOrEmpty(EnabledItems.Get <string>(executionContext)))
                {
                    #region Set IsEnable
                    string[]  enabledItemList = EnabledItems.Get <string>(executionContext).Split(new char[] { ',' });
                    byte[]    binary          = Convert.FromBase64String(ec.Entities[0].Attributes["content"].ToString());
                    XDocument xDocExisting    = XDocument.Parse(UnicodeEncoding.UTF8.GetString(binary));
                    UpdateConfigXML(enabledItemList, xDocExisting, ns: ns, traceEnable: traceEnable);

                    ec.Entities[0].Attributes["content"] = Convert.ToBase64String(UnicodeEncoding.UTF8.GetBytes(xDocExisting.ToString()));
                    service.Update(ec.Entities[0]);

                    PublishWebResource(ec.Entities[0].Id, service);
                    #endregion
                }

                if (ec != null && ec.Entities.Count > 0)
                {
                    XDocument xDocData = XDocument.Parse(UnicodeEncoding.UTF8.GetString(Convert.FromBase64String(ec.Entities[0].Attributes["content"].ToString())));

                    Namespace.Set(executionContext, xDocData.Root.Attribute("HierarchyColumnNamespace").Value);
                    EnableTrace.Set(executionContext, string.Compare(xDocData.Root.Attribute("EnableTrace").Value, "true", true) == 0 ? true : false);

                    ConfigHtml.Set(executionContext, XmlToHtmlTransformation(service, xDocData));
                }
            }
            catch (FaultException <OrganizationServiceFault> e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());

                // Handle the exception.
                throw;
            }

            tracingService.Trace("Exiting CreateConfigXml.Execute(), Correlation Id: {0}", context.CorrelationId);
        }