Ejemplo n.º 1
0
 public string GeneratePublicId()
 {
     while (true)
     {
         var intValue = new Random().Next(int.MaxValue);
         var result   = Base32.ToBase32String(new Int32Converter(intValue).ToBytes());
         if (!Diagrams.Any(d => d.PublicId == result))
         {
             return(result);
         }
     }
 }
Ejemplo n.º 2
0
 private void TypesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     foreach (var newItem in e.NewItems)
     {
         Type type = newItem as Type;
         if (type.GetInterface(typeof(IDiagram).FullName, false) != null)
         {
             IDiagram diagram = (IDiagram)Activator.CreateInstance(type);
             if (!Diagrams.Any(item => item.GetType() == type))
             {
                 Diagrams.Add(diagram);
                 if (SelectedDiagram == null)
                 {
                     SelectedDiagram = diagram;
                 }
             }
         }
         else if (type.IsSubclassOf(typeof(ObjectType)))
         {
             AddSelectedDiagramType(type);
         }
     }
 }