Esempio n. 1
0
        /// <summary>
        /// Creates a brand new graph which has an x-y plot layer. The graph is not named, nor is it already part of the project.
        /// </summary>
        /// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated or the folder.</param>
        /// <returns>The created graph.</returns>
        private static GraphDocument CreateBuiltinGraph(IReadOnlyPropertyBag propertyContext)
        {
            if (null == propertyContext)
            {
                propertyContext = PropertyExtensions.GetPropertyContextOfProject();
            }

            var graph = new Altaxo.Graph.Gdi.GraphDocument();

            TemplateBase.AddStandardPropertiesToGraph(graph, propertyContext);
            graph.RootLayer.Location.CopyFrom(propertyContext.GetValue(Altaxo.Graph.Gdi.GraphDocument.PropertyKeyDefaultRootLayerSize)); // apply the default location from the property in the path

            var layer = new Altaxo.Graph.Gdi.XYPlotLayer(graph.RootLayer, new Altaxo.Graph.Gdi.CS.G2DPolarCoordinateSystem());

            layer.Scales[0] = new Scales.AngularDegreeScale()
            {
                TickSpacing = new Scales.Ticks.AngularDegreeTickSpacing()
            };

            layer.CreateDefaultAxes(propertyContext);

            layer.AxisStyles[CSLineID.X1].AxisLineStyle.FirstDownMajorTicks = false;
            layer.AxisStyles[CSLineID.X1].AxisLineStyle.FirstDownMinorTicks = false;
            layer.AxisStyles[CSLineID.Y0].AxisLineStyle.FirstUpMajorTicks   = false;
            layer.AxisStyles[CSLineID.Y0].AxisLineStyle.FirstUpMinorTicks   = false;

            graph.RootLayer.Layers.Add(layer);

            return(graph);
        }
            public MailboxAuditLogRecord Convert(IReadOnlyPropertyBag propertyBag)
            {
                ObjectId   itemId       = propertyBag[ItemSchema.Id] as ObjectId;
                ExDateTime creationTime = (ExDateTime)propertyBag[StoreObjectSchema.CreationTime];

                return(this.search.ReadAuditLogRecord(itemId, creationTime, propertyBag[ItemSchema.TextBody] as string));
            }
Esempio n. 3
0
            public AdminAuditLogEvent Convert(IReadOnlyPropertyBag propertyBag)
            {
                ObjectId             storeId  = propertyBag[ItemSchema.Id] as ObjectId;
                AdminAuditLogEventId identity = new AdminAuditLogEventId(storeId);

                return(new AdminAuditLogEvent(identity, propertyBag[ItemSchema.TextBody] as string));
            }
Esempio n. 4
0
        private static bool EvaluateExistsFilter(ExistsFilter existsFilter, IReadOnlyPropertyBag propertyBag)
        {
            object        obj           = propertyBag[existsFilter.Property];
            PropertyError propertyError = obj as PropertyError;

            if (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound)
            {
                return(false);
            }
            if (propertyBag is ADPropertyBag || propertyBag is ADRawEntry)
            {
                if (obj == null)
                {
                    return(false);
                }
                if (obj is string && string.IsNullOrEmpty((string)obj))
                {
                    return(false);
                }
                if (obj is SmtpAddress && !((SmtpAddress)obj).IsValidAddress)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 5
0
        private static bool IsPropertyError(IReadOnlyPropertyBag propertyBag, PropertyDefinition property, bool shouldThrow)
        {
            object obj = propertyBag[property];

            if (obj != null)
            {
                PropertyError propertyError = obj as PropertyError;
                if (propertyError != null)
                {
                    if (shouldThrow)
                    {
                        throw PropertyErrorException.FromPropertyErrorsInternal(new PropertyError[]
                        {
                            obj as PropertyError
                        });
                    }
                    return(true);
                }
            }
            else if (propertyBag is ADPropertyBag || propertyBag is ADRawEntry)
            {
                if (shouldThrow)
                {
                    throw PropertyErrorException.FromPropertyErrorsInternal(new PropertyError[]
                    {
                        new PropertyError(property, PropertyErrorCode.NotFound)
                    });
                }
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
        private static bool EvaluateBitMaskFilter(BitMaskFilter bitMaskFilter, IReadOnlyPropertyBag propertyBag, bool shouldThrow)
        {
            object obj = null;

            try
            {
                obj = propertyBag[bitMaskFilter.Property];
            }
            catch (PropertyErrorException)
            {
                if (shouldThrow)
                {
                    throw;
                }
                return(false);
            }
            if (EvaluatableFilter.IsPropertyError(propertyBag, bitMaskFilter.Property, shouldThrow))
            {
                return(false);
            }
            if (bitMaskFilter.IsNonZero)
            {
                return(0UL != ((ulong)obj & bitMaskFilter.Mask));
            }
            return(0UL == ((ulong)obj & bitMaskFilter.Mask));
        }
Esempio n. 7
0
        // Token: 0x06000900 RID: 2304 RVA: 0x000238E4 File Offset: 0x00021AE4
        internal List <ConditionalResults> Evaluate(IReadOnlyPropertyBag propertyBag)
        {
            List <BaseConditionalRegistration> values = this.cache.Values;

            if (values == null || values.Count == 0)
            {
                return(null);
            }
            List <ConditionalResults> list = null;

            foreach (BaseConditionalRegistration baseConditionalRegistration in values)
            {
                ConditionalResults conditionalResults = baseConditionalRegistration.Evaluate(propertyBag);
                if (conditionalResults != null)
                {
                    if (list == null)
                    {
                        list = new List <ConditionalResults>();
                    }
                    list.Add(conditionalResults);
                    ConditionalRegistration conditionalRegistration = baseConditionalRegistration as ConditionalRegistration;
                    if (conditionalRegistration != null)
                    {
                        int currentHits = conditionalRegistration.CurrentHits;
                        if (currentHits >= conditionalRegistration.MaxHits)
                        {
                            ExTraceGlobals.DiagnosticHandlersTracer.TraceDebug <string, int, int>((long)this.GetHashCode(), "[ConditionalRegistrationCache.Evaluate] Removing entry '{0}' because current hits {1} exceeds MaxHits {2}.", conditionalRegistration.Cookie, currentHits, conditionalRegistration.MaxHits);
                            this.cache.Remove(baseConditionalRegistration.Cookie);
                        }
                    }
                }
            }
            return(list);
        }
        /// <summary>
        /// Creates a brand new graph which has an x-y plot layer. The graph is not named, nor is it already part of the project.
        /// </summary>
        /// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated or the folder.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <returns>The created graph.</returns>
        private static GraphDocument CreateBuiltinGraph(IReadOnlyPropertyBag propertyContext, string folderName)
        {
            if (null == propertyContext)
            {
                if (null != folderName)
                {
                    propertyContext = Altaxo.PropertyExtensions.GetPropertyContextOfProjectFolder(folderName);
                }
                else
                {
                    propertyContext = PropertyExtensions.GetPropertyContextOfProject();
                }
            }

            var graph = new GraphDocument();

            TemplateBase.AddStandardPropertiesToGraph(graph, propertyContext);

            // apply the default location from the property in the path
            graph.RootLayer.Location.CopyFrom(propertyContext.GetValue(GraphDocument.PropertyKeyDefaultRootLayerSize));
            var layer = new XYZPlotLayer(graph.RootLayer, new CS.G3DCartesicCoordinateSystem());

            graph.RootLayer.Layers.Add(layer);
            layer.CreateDefaultAxes(propertyContext);
            graph.ViewToRootLayerCenter(new VectorD3D(-1, -2, 1), new VectorD3D(0, 0, 1), 1);

            return(graph);
        }
Esempio n. 9
0
 private static object GetGuid(IReadOnlyPropertyBag propertyBag)
 {
     if ((Guid)propertyBag[ADObjectSchema.Guid] == Guid.Empty)
     {
         return(PropertyErrorCode.NotFound);
     }
     return(((Guid)propertyBag[ADObjectSchema.Guid]).ToByteArray());
 }
Esempio n. 10
0
 public static bool FilterMatches(QueryFilter filter, IReadOnlyPropertyBag obj)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     return(OpathFilterEvaluator.FilterMatches(filter, obj, null));
 }
Esempio n. 11
0
        public static NamedColor GetDefaultForeColor(IReadOnlyPropertyBag context)
        {
            if (null == context)
            {
                context = PropertyExtensions.GetPropertyContextOfProject();
            }

            return(context.GetValue <NamedColor>(PropertyKeyDefaultForeColor));
        }
Esempio n. 12
0
        // Token: 0x060071EF RID: 29167 RVA: 0x00179AD0 File Offset: 0x00177CD0
        internal BudgetCacheHandlerMetadata GetMetadata(string filter)
        {
            QueryFilter queryFilter = null;

            if (!string.IsNullOrEmpty(filter))
            {
                queryFilter = BudgetCache <T> .ParseWhereClause(filter);
            }
            List <T> values = base.Values;
            BudgetCacheHandlerMetadata budgetCacheHandlerMetadata = new BudgetCacheHandlerMetadata();

            budgetCacheHandlerMetadata.TotalCount = base.Count;
            budgetCacheHandlerMetadata.Efficiency = this.CacheEfficiency;
            budgetCacheHandlerMetadata.Budgets    = new List <BudgetHandlerMetadata>();
            foreach (T t in values)
            {
                Budget budget = t;
                if (queryFilter != null)
                {
                    IReadOnlyPropertyBag readOnlyPropertyBag = budget;
                    if (readOnlyPropertyBag != null && !OpathFilterEvaluator.FilterMatches(queryFilter, readOnlyPropertyBag))
                    {
                        continue;
                    }
                }
                if (budget.Owner.IsServiceAccountBudget)
                {
                    budgetCacheHandlerMetadata.ServiceAccountBudgets++;
                }
                BudgetHandlerMetadata budgetHandlerMetadata = new BudgetHandlerMetadata();
                budgetHandlerMetadata.Locked      = false;
                budgetHandlerMetadata.LockedAt    = null;
                budgetHandlerMetadata.LockedUntil = null;
                float balance = budget.CasTokenBucket.GetBalance();
                if (balance >= 0f)
                {
                    budgetCacheHandlerMetadata.NotThrottled++;
                }
                else if (budget.CasTokenBucket.Locked)
                {
                    budgetHandlerMetadata.Locked      = true;
                    budgetHandlerMetadata.LockedAt    = budget.CasTokenBucket.LockedAt.ToString();
                    budgetHandlerMetadata.LockedUntil = budget.CasTokenBucket.LockedUntilUtc.ToString();
                    budgetCacheHandlerMetadata.InCutoff++;
                }
                else
                {
                    budgetCacheHandlerMetadata.InMicroDelay++;
                }
                budgetHandlerMetadata.Key = budget.Owner.ToString();
                budgetHandlerMetadata.OutstandingActions = budget.OutstandingActionsCount;
                budgetHandlerMetadata.Snapshot           = budget.ToString();
                budgetCacheHandlerMetadata.Budgets.Add(budgetHandlerMetadata);
            }
            budgetCacheHandlerMetadata.MatchingCount = budgetCacheHandlerMetadata.Budgets.Count;
            return(budgetCacheHandlerMetadata);
        }
Esempio n. 13
0
        /// <summary>
        /// Creates a new graph, which has an x-y plot layer with an polar coordinate system. The name of the graph will be prepared, so that it is ready to be included in the project. However, it is not already included in the project.
        /// </summary>
        /// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated from or the folder.</param>
        /// <param name="preferredGraphName">The name that is preferred for the new graph.</param>
        /// <param name="anyNameInSameFolder">Any name of an item in the same folder. This name is used to determine the destination folder of the graph.</param>
        /// <param name="includeInProject">If <c>true</c>, the graph is also included into the current project.</param>
        /// <returns>The created graph. The graph is already part of the project. (But no view is created for the graph).</returns>
        public static GraphDocument CreateGraph(IReadOnlyPropertyBag propertyContext, string preferredGraphName, string anyNameInSameFolder, bool includeInProject)
        {
            if (null == propertyContext)
            {
                propertyContext = PropertyExtensions.GetPropertyContextOfProject();
            }

            GraphDocument graph;
            var           graphTemplate = propertyContext.GetValue <GraphDocument>(PropertyKeyDefaultTemplate);
            bool          isBuiltinPolarPlotTemplate = object.ReferenceEquals(graphTemplate, Current.PropertyService.BuiltinSettings.GetValue <GraphDocument>(PropertyKeyDefaultTemplate));

            GraphDocument graphTemplateCartesic        = null;
            bool          isLineScatterTemplateBuiltin = false;

            if (isBuiltinPolarPlotTemplate)
            {
                graphTemplateCartesic        = propertyContext.GetValue <GraphDocument>(TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.PropertyKeyDefaultTemplate);
                isLineScatterTemplateBuiltin = object.ReferenceEquals(graphTemplateCartesic, Current.PropertyService.BuiltinSettings.GetValue <GraphDocument>(TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.PropertyKeyDefaultTemplate));
            }

            if (!isLineScatterTemplateBuiltin && isBuiltinPolarPlotTemplate)
            {
                graph = (GraphDocument)graphTemplateCartesic.Clone();
                // because we use the template with cartesic coordinate system here, we have to replace it by a polar coordinate systen
                var layer = graph.RootLayer.Layers.OfType <XYPlotLayer>().First();

                layer.CoordinateSystem = new CS.G2DPolarCoordinateSystem();
                layer.AxisStyles.Clear();
                layer.CreateDefaultAxes(graph.GetPropertyContext());
            }
            else if (!isBuiltinPolarPlotTemplate)
            {
                graph = (GraphDocument)graphTemplate.Clone();
            }
            else
            {
                graph = CreateBuiltinGraph(null);
            }

            if (string.IsNullOrEmpty(preferredGraphName))
            {
                string newnamebase = Altaxo.Main.ProjectFolder.CreateFullName(anyNameInSameFolder, "GRAPH");
                graph.Name = Current.Project.GraphDocumentCollection.FindNewItemName(newnamebase);
            }
            else
            {
                graph.Name = preferredGraphName;
            }

            if (includeInProject)
            {
                Current.Project.GraphDocumentCollection.Add(graph);
            }

            return(graph);
        }
Esempio n. 14
0
            public bool RecordFilter(IReadOnlyPropertyBag propertyBag, out bool stopNow)
            {
                stopNow = false;
                ObjectId objectId = propertyBag[ItemSchema.Id] as ObjectId;
                string   value    = propertyBag[ItemSchema.TextBody] as string;
                bool     result   = objectId != null && !string.IsNullOrEmpty(value) && this.currentIndex >= this.searchCriteria.StartIndex;

                this.currentIndex++;
                return(result);
            }
        public void UpdateManifestFromItem(ISyncItem item)
        {
            IReadOnlyPropertyBag readOnlyPropertyBag = item.NativeItem as IReadOnlyPropertyBag;

            if (readOnlyPropertyBag == null)
            {
                return;
            }
            this.UpdateManifestFromPropertyBag(readOnlyPropertyBag);
        }
Esempio n. 16
0
 // Token: 0x060008DD RID: 2269 RVA: 0x00022FB4 File Offset: 0x000211B4
 public ConditionalResults Evaluate(IReadOnlyPropertyBag propertyBag)
 {
     if (this.ShouldEvaluate && OpathFilterEvaluator.FilterMatches(this.QueryFilter, propertyBag))
     {
         Interlocked.Increment(ref this.hits);
         this.LastHitUtc = TimeProvider.UtcNow;
         return(this.FetchData(propertyBag));
     }
     return(null);
 }
Esempio n. 17
0
        private static object DefaultToNotFound(IReadOnlyPropertyBag properyBag, ADPropertyDefinition propDef)
        {
            object obj = properyBag[propDef];

            if (object.Equals(obj, propDef.DefaultValue))
            {
                return(PropertyErrorCode.NotFound);
            }
            return(obj);
        }
Esempio n. 18
0
 private static bool EvaluateOrFilter(OrFilter filterOr, IReadOnlyPropertyBag propertyBag, bool shouldThrow)
 {
     foreach (QueryFilter filter in filterOr.Filters)
     {
         if (EvaluatableFilter.Evaluate(filter, propertyBag, shouldThrow))
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 19
0
        private static object GetDisplayTypeEx(IReadOnlyPropertyBag propertyBag)
        {
            RecipientDisplayType?recipientDisplayType  = (RecipientDisplayType?)StoreToDirectorySchemaConverter.TryGetValueOrDefault(propertyBag, ADRecipientSchema.RecipientDisplayType);
            RecipientDisplayType?recipientDisplayType2 = (recipientDisplayType != null) ? new RecipientDisplayType?(recipientDisplayType.GetValueOrDefault()) : StoreToDirectorySchemaConverter.ToRecipientDisplayType((RecipientType)StoreToDirectorySchemaConverter.TryGetValueOrDefault(propertyBag, ADRecipientSchema.RecipientType));

            if (recipientDisplayType2 == null)
            {
                return(PropertyErrorCode.NotFound);
            }
            return((int)recipientDisplayType2.Value);
        }
        // Token: 0x0600063F RID: 1599 RVA: 0x0002FC3C File Offset: 0x0002DE3C
        bool IAuditRecordStrategy <ItemData> .RecordFilter(IReadOnlyPropertyBag propertyBag, out bool stopNow)
        {
            stopNow = false;
            VersionedId versionedId = propertyBag[ItemSchema.Id] as VersionedId;

            if (versionedId == null)
            {
                if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.ErrorTrace))
                {
                    AuditExpirationEnforcer.Tracer.TraceError <AuditExpirationEnforcer>((long)this.GetHashCode(), "{0}: We could not get id of this item. Skipping it.", this);
                }
                return(false);
            }
            if (ElcGlobals.ExpireDumpsterRightNow)
            {
                return(true);
            }
            object obj = propertyBag[StoreObjectSchema.CreationTime];

            if (!ElcMailboxHelper.Exists(obj))
            {
                if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    AuditExpirationEnforcer.Tracer.TraceDebug <AuditExpirationEnforcer>((long)this.GetHashCode(), "{0}: CreationTime date is missing. Skipping the item.", this);
                }
                return(false);
            }
            DateTime dateTime = (DateTime)((ExDateTime)obj).ToUtc();

            if (dateTime > this.expirationTime)
            {
                if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    AuditExpirationEnforcer.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Item {1} newer than minAgeLimitForFolder. Item:{2}, Limit:{3}.", new object[]
                    {
                        this,
                        versionedId,
                        dateTime,
                        this.expirationTime
                    });
                }
                stopNow = true;
                return(false);
            }
            if (this.oldestExpiringLog.CompareTo(DateTime.MinValue) == 0)
            {
                this.oldestExpiringLog = dateTime;
            }
            else if (dateTime.CompareTo(this.oldestExpiringLog) < 0)
            {
                this.oldestExpiringLog = dateTime;
            }
            return(true);
        }
Esempio n. 21
0
 public static FontX3D GetDefaultFont(IReadOnlyPropertyBag context)
 {
     if (null != context)
     {
         return(context.GetValue(PropertyKeyDefaultFont));
     }
     else
     {
         return(new FontX3D(Gdi.GdiFontManager.GetFontXGenericSansSerif(12, FontXStyle.Regular), 12 * 0.0625));
     }
 }
Esempio n. 22
0
        // Token: 0x0600065F RID: 1631 RVA: 0x0003089C File Offset: 0x0002EA9C
        ItemData IAuditRecordStrategy <ItemData> .Convert(IReadOnlyPropertyBag propertyBag)
        {
            VersionedId itemId      = propertyBag[ItemSchema.Id] as VersionedId;
            object      obj         = propertyBag[ItemSchema.Size];
            int         messageSize = 0;

            if (obj != null && obj is int)
            {
                messageSize = (int)obj;
            }
            return(new ItemData(itemId, messageSize));
        }
Esempio n. 23
0
        private static object GetSipUri(IReadOnlyPropertyBag propertyBag)
        {
            ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)propertyBag[ADRecipientSchema.EmailAddresses];

            foreach (ProxyAddress proxyAddress in proxyAddressCollection)
            {
                if (proxyAddress.PrefixString.Equals("sip", StringComparison.OrdinalIgnoreCase))
                {
                    return(proxyAddress.ProxyAddressString.ToLower());
                }
            }
            return(" ");
        }
Esempio n. 24
0
 private void AddType(System.Type t, string group)
 {
     if (MonoMain.lockLoading)
     {
         MonoMain.loadingLocked = true;
         while (MonoMain.lockLoading)
         {
             Thread.Sleep(10);
         }
     }
     MonoMain.loadingLocked = false;
     if (group == "survival")
     {
         return;
     }
     if (group == "")
     {
         Main.SpecialCode = "creating " + t.AssemblyQualifiedName;
         Thing typeInstance = Editor.GetOrCreateTypeInstance(t);
         Main.SpecialCode = "accessing " + t.AssemblyQualifiedName;
         IReadOnlyPropertyBag bag = ContentProperties.GetBag(t);
         if (bag.GetOrDefault <bool>("isInDemo", false))
         {
             this._filteredThings.Add(typeInstance);
         }
         if (bag.GetOrDefault <bool>("isOnlineCapable", true))
         {
             this._onlineFilteredThings.Add(typeInstance);
         }
         this._things.Add(typeInstance);
         this._types.Add(t);
         Editor.MapThing(typeInstance);
         ++MonoMain.lazyLoadyBits;
         Main.SpecialCode = "finished " + t.AssemblyQualifiedName;
     }
     else
     {
         string[]    groupName   = group.Split('|');
         EditorGroup editorGroup = this.SubGroups.FirstOrDefault <EditorGroup>((Func <EditorGroup, bool>)(x => x.Name == groupName[0]));
         if (editorGroup == null)
         {
             editorGroup      = new EditorGroup();
             editorGroup.Name = groupName[0];
             this.SubGroups.Add(editorGroup);
         }
         string str    = group;
         string group1 = ((IEnumerable <string>)groupName).Count <string>() <= 1 ? str.Remove(0, groupName[0].Length) : str.Remove(0, groupName[0].Length + 1);
         editorGroup.AddType(t, group1);
     }
 }
Esempio n. 25
0
        // Token: 0x060008DE RID: 2270 RVA: 0x00022FEC File Offset: 0x000211EC
        private ConditionalResults FetchData(IReadOnlyPropertyBag propertyBag)
        {
            Dictionary <PropertyDefinition, object> dictionary = new Dictionary <PropertyDefinition, object>();

            foreach (PropertyDefinition propertyDefinition in this.PropertiesToFetch)
            {
                object obj = propertyBag[propertyDefinition];
                if (obj != null)
                {
                    dictionary[propertyDefinition] = obj;
                }
            }
            return(new ConditionalResults(this, RegistrationResult.Success, dictionary));
        }
Esempio n. 26
0
        /// <summary>
        /// Creates the axis style with ShowAxisLine = true and ShowMajorLabels = true
        /// </summary>
        /// <param name="info">The axis information.</param>
        /// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param>
        /// <returns>The newly created axis style, if it was not in the collection before. Returns the unchanged axis style, if it was present already in the collection.</returns>
        public AxisStyle CreateDefault(CSAxisInformation info, IReadOnlyPropertyBag context)
        {
            AxisStyle prop = this[info.Identifier];

            if (prop == null)
            {
                prop = new AxisStyle(info, true, info.HasTicksByDefault, false, null, context)
                {
                    CachedAxisInformation = _cachedCoordinateSystem.GetAxisStyleInformation(info.Identifier)
                };
                Add(prop);
            }
            return(prop);
        }
Esempio n. 27
0
        /// <summary>
        /// Creates the axis style with ShowAxisLine = true and ShowMajorLabels = true
        /// </summary>
        /// <param name="id">The axis style identifier.</param>
        /// <param name="context">Property context used to determine default values, e.g. for the pen width or symbol size.</param>
        /// <returns>The newly created axis style, if it was not in the collection before. Returns the unchanged axis style, if it was present already in the collection.</returns>
        public AxisStyle CreateDefault(CSLineID id, IReadOnlyPropertyBag context)
        {
            AxisStyle prop = this[id];

            if (prop == null)
            {
                prop = new AxisStyle(id, true, true, false, null, context)
                {
                    CachedAxisInformation = _cachedCoordinateSystem.GetAxisStyleInformation(id)
                };
                Add(prop);
            }
            return(prop);
        }
Esempio n. 28
0
        private static object TryGetValueOrDefault(IReadOnlyPropertyBag properyBag, ADPropertyDefinition propDef)
        {
            object result;

            try
            {
                result = properyBag[propDef];
            }
            catch (ValueNotPresentException)
            {
                result = propDef.DefaultValue;
            }
            return(result);
        }
Esempio n. 29
0
        private static object GetParticipantSid(IReadOnlyPropertyBag propertyBag)
        {
            SecurityIdentifier userSid            = (SecurityIdentifier)propertyBag[ADMailboxRecipientSchema.Sid];
            SecurityIdentifier masterAccountSid   = (SecurityIdentifier)propertyBag[ADRecipientSchema.MasterAccountSid];
            SecurityIdentifier securityIdentifier = IdentityHelper.CalculateEffectiveSid(userSid, masterAccountSid);

            if (securityIdentifier == null)
            {
                return(PropertyErrorCode.NotFound);
            }
            byte[] array = new byte[securityIdentifier.BinaryLength];
            securityIdentifier.GetBinaryForm(array, 0);
            return(array);
        }
 public void UpdateManifestFromPropertyBag(IReadOnlyPropertyBag propertyBag)
 {
     this.messageClass = (propertyBag[InternalSchema.ItemClass] as string);
     try
     {
         object obj = propertyBag[ItemSchema.ReceivedTime];
         if (obj is ExDateTime)
         {
             this.filterDate = new ExDateTime?((ExDateTime)obj);
         }
     }
     catch (PropertyErrorException)
     {
         this.filterDate = null;
     }
     try
     {
         object obj = propertyBag[ItemSchema.ConversationId];
         if (obj is ConversationId)
         {
             this.conversationId = (ConversationId)obj;
         }
         obj = propertyBag[ItemSchema.ConversationIndex];
         ConversationIndex index;
         if (obj is byte[] && ConversationIndex.TryCreate((byte[])obj, out index) && index != ConversationIndex.Empty && index.Components != null && index.Components.Count == 1)
         {
             this.firstMessageInConversation = true;
         }
     }
     catch (PropertyErrorException)
     {
         this.conversationId             = null;
         this.firstMessageInConversation = false;
     }
     try
     {
         object obj = propertyBag[MessageItemSchema.IsRead];
         if (obj is bool)
         {
             this.itemRead = (((bool)obj) ? ServerManifestEntry.ReadFlagState.Read : ServerManifestEntry.ReadFlagState.UnRead);
         }
     }
     catch (PropertyErrorException)
     {
         this.itemRead = ServerManifestEntry.ReadFlagState.Unknown;
     }
 }
		/// <summary>
		/// Creates a brand new graph which has an x-y plot layer. The graph is not named, nor is it already part of the project.
		/// </summary>
		/// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated or the folder.</param>
		/// <returns>The created graph.</returns>
		private static GraphDocument CreateBuiltinGraph(IReadOnlyPropertyBag propertyContext)
		{
			if (null == propertyContext)
				propertyContext = PropertyExtensions.GetPropertyContextOfProject();

			var graph = new GraphDocument();
			TemplateBase.AddStandardPropertiesToGraph(graph, propertyContext);

			// apply the default location from the property in the path
			graph.RootLayer.Location.CopyFrom(propertyContext.GetValue(Altaxo.Graph.Gdi.GraphDocument.PropertyKeyDefaultRootLayerSize));
			Altaxo.Graph.Gdi.XYPlotLayer layer = new Altaxo.Graph.Gdi.XYPlotLayer(graph.RootLayer);
			layer.CreateDefaultAxes(propertyContext);
			layer.AxisStyles[CSLineID.X0].AxisLineStyle.FirstUpMajorTicks = false;
			layer.AxisStyles[CSLineID.X0].AxisLineStyle.FirstUpMinorTicks = false;
			layer.AxisStyles[CSLineID.Y0].AxisLineStyle.FirstUpMajorTicks = false;
			layer.AxisStyles[CSLineID.Y0].AxisLineStyle.FirstUpMinorTicks = false;
			graph.RootLayer.Layers.Add(layer);

			return graph;
		}
		/// <summary>
		/// Creates a brand new graph which has an x-y plot layer. The graph is not named, nor is it already part of the project.
		/// </summary>
		/// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated or the folder.</param>
		/// <param name="folderName">Name of the folder.</param>
		/// <returns>The created graph.</returns>
		private static GraphDocument CreateBuiltinGraph(IReadOnlyPropertyBag propertyContext, string folderName)
		{
			if (null == propertyContext)
			{
				if (null != folderName)
					propertyContext = Altaxo.PropertyExtensions.GetPropertyContextOfProjectFolder(folderName);
				else
					propertyContext = PropertyExtensions.GetPropertyContextOfProject();
			}

			var graph = new GraphDocument();
			TemplateBase.AddStandardPropertiesToGraph(graph, propertyContext);

			// apply the default location from the property in the path
			graph.RootLayer.Location.CopyFrom(propertyContext.GetValue(GraphDocument.PropertyKeyDefaultRootLayerSize));
			var layer = new XYZPlotLayer(graph.RootLayer, new CS.G3DCartesicCoordinateSystem());
			graph.RootLayer.Layers.Add(layer);
			layer.CreateDefaultAxes(propertyContext);
			graph.ViewToRootLayerCenter(new VectorD3D(-1, -2, 1), new VectorD3D(0, 0, 1), 1);

			return graph;
		}
		/// <summary>
		/// Creates a brand new graph which has an x-y plot layer. The graph is not named, nor is it already part of the project.
		/// </summary>
		/// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated or the folder.</param>
		/// <returns>The created graph.</returns>
		private static GraphDocument CreateBuiltinGraph(IReadOnlyPropertyBag propertyContext)
		{
			if (null == propertyContext)
				propertyContext = PropertyExtensions.GetPropertyContextOfProject();

			Altaxo.Graph.Gdi.GraphDocument graph = new Altaxo.Graph.Gdi.GraphDocument();
			TemplateBase.AddStandardPropertiesToGraph(graph, propertyContext);
			graph.RootLayer.Location.CopyFrom(propertyContext.GetValue(Altaxo.Graph.Gdi.GraphDocument.PropertyKeyDefaultRootLayerSize));  // apply the default location from the property in the path

			Altaxo.Graph.Gdi.XYPlotLayer layer = new Altaxo.Graph.Gdi.XYPlotLayer(graph.RootLayer, new Altaxo.Graph.Gdi.CS.G2DPolarCoordinateSystem());
			layer.Scales[0] = new Scales.AngularDegreeScale() { TickSpacing = new Scales.Ticks.AngularDegreeTickSpacing() };

			layer.CreateDefaultAxes(propertyContext);

			layer.AxisStyles[CSLineID.X1].AxisLineStyle.FirstDownMajorTicks = false;
			layer.AxisStyles[CSLineID.X1].AxisLineStyle.FirstDownMinorTicks = false;
			layer.AxisStyles[CSLineID.Y0].AxisLineStyle.FirstUpMajorTicks = false;
			layer.AxisStyles[CSLineID.Y0].AxisLineStyle.FirstUpMinorTicks = false;

			graph.RootLayer.Layers.Add(layer);

			return graph;
		}
Esempio n. 34
0
		/// <summary>
		/// This will create the default axes styles that are given by the coordinate system.
		/// </summary>
		public void CreateDefaultAxes(IReadOnlyPropertyBag context)
		{
			foreach (CSAxisInformation info in CoordinateSystem.AxisStyles)
			{
				if (info.IsShownByDefault)
				{
					this.AxisStyles.CreateDefault(info, context);

					if (info.HasTitleByDefault)
					{
						this.SetAxisTitleString(info.Identifier, info.Identifier.ParallelAxisNumber == 0 ? "X axis" : info.Identifier.ParallelAxisNumber == 1 ? "Y axis" : "Z axis");
					}
				}
			}
		}
Esempio n. 35
0
		private void ShowAxisLine(bool hasTicksByDefault, CSAxisSide preferredTickSide, IReadOnlyPropertyBag context)
		{
			if (_axisLineStyle == null)
				AxisLineStyle = new AxisLineStyle(hasTicksByDefault, preferredTickSide, context);
		}
		/// <summary>
		/// Creates a new graph, which has an x-y plot layer with an polar coordinate system. The name of the graph will be prepared, so that it is ready to be included in the project. However, it is not already included in the project.
		/// </summary>
		/// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated from or the folder.</param>
		/// <param name="preferredGraphName">The name that is preferred for the new graph.</param>
		/// <param name="anyNameInSameFolder">Any name of an item in the same folder. This name is used to determine the destination folder of the graph.</param>
		/// <param name="includeInProject">If <c>true</c>, the graph is also included into the current project.</param>
		/// <returns>The created graph. The graph is already part of the project. (But no view is created for the graph).</returns>
		public static GraphDocument CreateGraph(IReadOnlyPropertyBag propertyContext, string preferredGraphName, string anyNameInSameFolder, bool includeInProject)
		{
			if (null == propertyContext)
				propertyContext = PropertyExtensions.GetPropertyContextOfProject();

			GraphDocument graph;
			var graphTemplate = propertyContext.GetValue<GraphDocument>(PropertyKeyDefaultTemplate);
			bool isBuiltinPolarPlotTemplate = object.ReferenceEquals(graphTemplate, Current.PropertyService.BuiltinSettings.GetValue<GraphDocument>(PropertyKeyDefaultTemplate));

			GraphDocument graphTemplateCartesic = null;
			bool isLineScatterTemplateBuiltin = false;

			if (isBuiltinPolarPlotTemplate)
			{
				graphTemplateCartesic = propertyContext.GetValue<GraphDocument>(TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.PropertyKeyDefaultTemplate);
				isLineScatterTemplateBuiltin = object.ReferenceEquals(graphTemplateCartesic, Current.PropertyService.BuiltinSettings.GetValue<GraphDocument>(TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.PropertyKeyDefaultTemplate));
			}

			if (!isLineScatterTemplateBuiltin && isBuiltinPolarPlotTemplate)
			{
				graph = (GraphDocument)graphTemplateCartesic.Clone();
				// because we use the template with cartesic coordinate system here, we have to replace it by a polar coordinate systen
				var layer = graph.RootLayer.Layers.OfType<XYPlotLayer>().First();

				layer.CoordinateSystem = new CS.G2DPolarCoordinateSystem();
				layer.AxisStyles.Clear();
				layer.CreateDefaultAxes(graph.GetPropertyContext());
			}
			else if (!isBuiltinPolarPlotTemplate)
			{
				graph = (GraphDocument)graphTemplate.Clone();
			}
			else
			{
				graph = CreateBuiltinGraph(null);
			}

			if (string.IsNullOrEmpty(preferredGraphName))
			{
				string newnamebase = Altaxo.Main.ProjectFolder.CreateFullName(anyNameInSameFolder, "GRAPH");
				graph.Name = Current.Project.GraphDocumentCollection.FindNewName(newnamebase);
			}
			else
			{
				graph.Name = preferredGraphName;
			}

			if (includeInProject)
				Current.Project.GraphDocumentCollection.Add(graph);

			return graph;
		}
Esempio n. 37
0
		public static void AddStandardPropertiesToGraph(GraphDocument graph, IReadOnlyPropertyBag propertyContext)
		{
			// Set default font property exclusively for the graph
			graph.PropertyBagNotNull.SetValue<FontX3D>(GraphDocument.PropertyKeyDefaultFont, propertyContext.GetValue<FontX3D>(GraphDocument.PropertyKeyDefaultFont));
		}
		/// <summary>
		/// Creates a new graph, which has an x-y plot layer. The name of the graph will be prepared, so that it is ready to be included in the project. However, it is not already included in the project.
		/// </summary>
		/// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated from or the folder.</param>
		/// <param name="preferredGraphName">The base graph name. If this name exist already, a new name is created, which is based on this argument.</param>
		/// <param name="anyNameInSameFolder">Any name of an item in the same folder. This name is used to determine the destination folder of the graph.</param>
		/// <param name="includeInProject">If true, the graph is included in the project.</param>
		/// <returns>The created graph. The graph is already part of the project. (But no view is created for the graph).</returns>
		public static GraphDocument CreateGraph(IReadOnlyPropertyBag propertyContext, string preferredGraphName, string anyNameInSameFolder, bool includeInProject)
		{
			string folderName = null == anyNameInSameFolder ? null : Altaxo.Main.ProjectFolder.GetFolderPart(anyNameInSameFolder);

			if (null == propertyContext)
			{
				if (null != anyNameInSameFolder)
					Altaxo.PropertyExtensions.GetPropertyContextOfProjectFolder(folderName);
				else
					propertyContext = PropertyExtensions.GetPropertyContextOfProject();
			}

			GraphDocument graph;
			var graphTemplate = propertyContext.GetValue<GraphDocument>(PropertyKeyDefaultTemplate);
			var isBuiltinTemplate = object.ReferenceEquals(graphTemplate, Current.PropertyService.BuiltinSettings.GetValue<GraphDocument>(PropertyKeyDefaultTemplate));
			if (null != graphTemplate && !isBuiltinTemplate)
				graph = (GraphDocument)graphTemplate.Clone();
			else
				graph = CreateBuiltinGraph(propertyContext, folderName);

			if (string.IsNullOrEmpty(preferredGraphName))
			{
				string newnamebase = Altaxo.Main.ProjectFolder.CreateFullName(anyNameInSameFolder, "GRAPH");
				graph.Name = Current.Project.GraphDocumentCollection.FindNewName(newnamebase);
			}
			else
			{
				graph.Name = preferredGraphName;
			}

			if (includeInProject)
				Current.Project.AddItem(graph);

			return graph;
		}