Beispiel #1
0
        protected virtual Lucene.Net.Search.Query CreateQuery(N2.Persistence.Search.Query query)
        {
            var q = "";
            if(!string.IsNullOrEmpty(query.Text))
                q = query.OnlyPages.HasValue
                     ? string.Format("+(Title:({0})^4 Text:({0}) PartsText:({0}))", query.Text)
                     : string.Format("+(Title:({0})^4 Text:({0}))", query.Text);

            if (query.Ancestor != null)
                q += string.Format(" +Trail:{0}*", Utility.GetTrail(query.Ancestor));
            if(query.OnlyPages.HasValue)
                q += string.Format(" +IsPage:{0}", query.OnlyPages.Value.ToString().ToLower());
            if (query.Roles != null)
                q += string.Format(" +Roles:(Everyone {0})", string.Join(" ", query.Roles.ToArray()));
            if (query.Types != null)
                q += string.Format(" +Types:({0})", string.Join(" ", query.Types.Select(t => t.Name).ToArray()));
            if (query.LanguageCode != null)
                q += string.Format(" +Language:({0})", query.LanguageCode);
            if (query.Exclution != null)
                q += string.Format(" -({0})", CreateQuery(query.Exclution));
            if (query.Intersection != null)
                q = string.Format("+({0}) +({1})", q, CreateQuery(query.Intersection));
            if (query.Union != null)
                q = string.Format("({0}) ({1})", q, CreateQuery(query.Union));

            Trace.WriteLine("CreateQuery: " + q);

            return accessor.GetQueryParser().Parse(q);
        }
Beispiel #2
0
 public Tracker(Persistence.IPersister persister, Persistence.Finder.IItemFinder find, N2.Web.IUrlParser urlParser, N2.Web.IErrorHandler errorHandler)
 {
     this.persister = persister;
     this.find = find;
     this.urlParser = urlParser;
     this.errorHandler = errorHandler;
 }
Beispiel #3
0
		private void ReplaceContent(N2.Engine.IEngine factory)
		{
			var installer = factory.Resolve<N2.Edit.Installation.InstallationManager>();
			installer.Install();
			var root = installer.InsertExportFile(File.OpenRead(HttpContext.Current.Server.MapPath("~/App_Data/Demo.n2.xml.gz")), "Concrete_SampleData.gz");
			if (root.ID != factory.Host.DefaultSite.RootItemID)
				factory.Host.DefaultSite.RootItemID = root.ID;
			foreach (ContentItem item in root.Children)
			{
				if (item.ID == factory.Host.DefaultSite.StartPageID && item is StartPage)
				{
					CreateDemoPanel(factory, item);
					return;
				}
			}

			foreach (ContentItem item in root.Children)
			{
				if (item is StartPage)
				{
					CreateDemoPanel(factory, item);
					factory.Host.DefaultSite.StartPageID = item.ID;
					return;
				}
			}
		}
        public override int GetHashCode()
        {
            int hash = 1;

            if (N1 != 0)
            {
                hash ^= N1.GetHashCode();
            }
            if (N2 != 0)
            {
                hash ^= N2.GetHashCode();
            }
            if (Soma != 0)
            {
                hash ^= Soma.GetHashCode();
            }
            if (Subtracao != 0)
            {
                hash ^= Subtracao.GetHashCode();
            }
            if (Multiplicacao != 0)
            {
                hash ^= Multiplicacao.GetHashCode();
            }
            if (Divisao != 0F)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Divisao);
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Beispiel #5
0
        public Result Search(N2.Persistence.Search.Query query)
        {
            if (!query.IsValid())
                return Result.Empty;

            var s = accessor.GetSearcher();
            try
            {
                var q = CreateQuery(query);
                var hits = s.Search(q, query.SkipHits + query.TakeHits);

                var result = new Result();
                result.Total = hits.totalHits;
                var resultHits = hits.scoreDocs.Skip(query.SkipHits).Take(query.TakeHits).Select(hit =>
                {
                    var doc = s.Doc(hit.doc);
                    int id = int.Parse(doc.Get("ID"));
                    ContentItem item = persister.Get(id);
                    return new Hit { Content = item, Score = hit.score };
                }).Where(h => h.Content != null).ToList();
                result.Hits = resultHits;
                result.Count = resultHits.Count;
                return result;
            }
            finally
            {
                //s.Close();
            }
        }
        public override void UpdateEditor(N2.ContentItem item, Control editor)
        {
            if (item == null)
                throw new ArgumentNullException("item", "item is null.");
            if (editor == null)
                throw new ArgumentNullException("editor", "editor is null.");

            ListBox lb = (ListBox)editor;
            string currentlySelectedItemsString = (string)item[this.Name] ?? string.Empty;

            if (!string.IsNullOrEmpty(currentlySelectedItemsString))
            {
                string[] currentlySelectedItems = currentlySelectedItemsString.Split(ItemSeperator);
                if (currentlySelectedItems.Length > 0)
                {
                    foreach (string currentItem in currentlySelectedItems)
                    {
                        ListItem listItem = lb.Items.FindByValue(currentItem);

                        if (listItem != null)
                            listItem.Selected = true;
                    }
                }
            }
        }
        static void Persister_SitemapChangeNeeded(object sender, N2.ItemEventArgs e)
        {
            DateTime published = e.AffectedItem.Published.GetValueOrDefault(DateTime.MaxValue);
            bool ignoreChange =
                published > DateTime.Now ||
                !e.AffectedItem.IsPage ||
                !AutoDefineOnType(e.AffectedItem.GetType());

            if (ignoreChange)
                return;

            IEnumerable<N2.ContentItem> sitemaps = Find.Items
                .Where
                // Add back when legacy compatibility is no longer an issue: .Type.Eq(typeof(SitemapXml))
                    .Type.NotEq(typeof(WebPage))
                //TODO: Remove all these Type.NotEq lines when we add back the .Type.Eq(typeof(SitemapXml)) line
                    .And.Type.NotEq(typeof(CustomContent))
                    .And.Type.NotEq(typeof(CustomCssContent))
                    .And.Type.NotEq(typeof(CustomHtmlContent))
                    .And.Type.NotEq(typeof(FeedPage))
                    .And.Type.NotEq(typeof(HomePage))
                    .And.Type.NotEq(typeof(LanguageHomePage))
                    .And.Type.NotEq(typeof(LanguageHomeRedirectPage))
                    .And.Type.NotEq(typeof(RedirectPage))
                    .And.IsPublished()
                .Select<N2.ContentItem>();
                //.Where(item => item.GetType().IsAssignableFrom(typeof(SitemapXml)))
                //.Cast<SitemapXml>();

            foreach (N2.ContentItem sitemap in sitemaps)
            {
                if(sitemap is SitemapXml)
                    ((SitemapXml)sitemap).Regenerate(Find.StartPage);
            }
        }
Beispiel #8
0
        public override IDictionary<string, System.Web.UI.Control> AddDefinedEditors(ItemDefinition definition, N2.ContentItem item, System.Web.UI.Control container, System.Security.Principal.IPrincipal user, Type containerTypeFilter, IEnumerable<string> editableNameFilter)
        {
            ItemDefinition cloned = null;

            // add a "wrap in container" checkbox to all parts that are within zones that are not wrapped in a container (BeforeMain, AfterMain).
            if (!definition.IsPage)
            {
                if (!(Defaults.IsContainerWrappable(item.ZoneName) ||
                      Defaults.IsContainerWrappable(System.Web.HttpContext.Current.Request["zoneName"])))
                {
                    cloned = definition.Clone();
                    var isWrappable = cloned.Editables.FirstOrDefault(x => x.Name == "UseContainer");
                    if (isWrappable != null)
                    {
                        cloned.Editables.Remove(isWrappable);
                    }
                }
            }

            if (item is IItemAdapter)
            {
                var result = (item as IItemAdapter).AddDefinedEditors(cloned ?? definition, container, user, containerTypeFilter, editableNameFilter);
                if (result != null)
                    return result;
            }
            return base.AddDefinedEditors(cloned ?? definition, item, container, user, containerTypeFilter, editableNameFilter);
        }
Beispiel #9
0
        private void MAJSuccesseurs(GenericNode N)
        {
            // On fait appel à GetListSucc, méthode abstraite qu'on doit réécrire pour chaque
            // problème. Elle doit retourner la liste complète des noeuds successeurs de N.
            List <GenericNode> listsucc = N.GetListSucc();

            foreach (GenericNode N2 in listsucc)
            {
                N2.GenericCas = N.GenericCas;
                // N2 est-il une copie d'un nœud déjà vu et placé dans la liste des fermés ?
                GenericNode N2bis = ChercheNodeDansFermes(N2);

                if (N2bis == null)
                {
                    // Rien dans les fermés. Est-il dans les ouverts ?
                    N2bis = ChercheNodeDansOuverts(N2);
                    if (N2bis != null)
                    {
                        N2bis.GenericCas = N.GenericCas;
                        // Il existe, donc on l'a déjà vu, N2 n'est qu'une copie de N2Bis

                        // Le nouveau chemin passant par N est-il meilleur ?
                        if (N.GetGCost() + N.GetArcCost(N2) < N2.GetGCost())
                        {
                            // Mise à jour de N2bis
                            N2bis.SetGCost(N.GetGCost() + N.GetArcCost(N2));
                            // HCost pas recalculé car toujours bon
                            N2bis.RecalculeCoutTotal(); // somme de GCost et HCost
                            // Mise à jour de la famille ....
                            N2bis.Supprime_Liens_Parent();
                            N2bis.SetNoeud_Parent(N);
                            // Mise à jour des ouverts
                            L_Ouverts.Remove(N2bis);
                            this.InsertNewNodeInOpenList(N2bis);
                        }
                        // else on ne fait rien, car le nouveau chemin est moins bon
                    }
                    else
                    {
                        // N2 est nouveau, MAJ et insertion dans les ouverts
                        N2.SetGCost(N.GetGCost() + N.GetArcCost(N2));
                        N2.SetNoeud_Parent(N);
                        N2.calculCoutTotal(); // somme de GCost et HCost

                        //essai : si le noeud a un cout de plus d'1 million on ne l'explore pas
                        if (N2.Cout_Total >= 1000000)
                        {
                            //nothing
                        }
                        else
                        {
                            this.InsertNewNodeInOpenList(N2);
                        }
                    }
                }
                // else il est dans les fermés donc on ne fait rien,
                // car on a déjà trouvé le plus court chemin pour aller en N2
            }
        }
        public override ItemList GetItemsInZone(N2.ContentItem parentItem, string zoneName)
        {
            ItemList items = base.GetItemsInZone(parentItem, zoneName);
            if (zoneName.StartsWith("Sectional") && parentItem != null && parentItem.IsPage)
                items.AddRange(GetItemsInZone(parentItem.GetSafeParent(), zoneName));

            return items;
        }
Beispiel #11
0
        protected internal void Regenerate(N2.ContentItem startingPoint)
        {
            if (startingPoint == null)
                throw new ArgumentNullException("startingPoint", "startingPoint is null.");

            this.SetDetail<string>(XmlKey, this.GenerateXml(startingPoint));
            N2.Context.Persister.Save(this);
        }
Beispiel #12
0
 private void Form1_Load(object sender, EventArgs e)
 {
     N1          = 0;
     N2          = 0;
     div.Enabled = false;
     tbN1.Text   = N1.ToString();
     tbN2.Text   = N2.ToString();
 }
Beispiel #13
0
 private void button2_Click(object sender, EventArgs e)
 {
     //投影系数
     N1            = (Bu * w2 - Bw * u2) / (u1 * w2 - u2 * w1);
     N2            = (Bu * w1 - Bw * u1) / (u1 * w2 - u2 * w1);
     textBox4.Text = N1.ToString("0.00000");
     textBox5.Text = N2.ToString("0.00000");
 }
Beispiel #14
0
        /// <summary>
        /// Implements <see cref="N2.Plugin.IPluginInitializer.Initialize"/> to register the 
        /// instance with N2 under its full type name.
        /// </summary>
        /// <param name="engine">Specifies the <see cref="N2.Engine.IEngine"/> instance to register
        /// the plug-in with.</param>
        public virtual void Initialize(N2.Engine.IEngine engine)
        {
            Type type = this.GetType();
            string fullName = type.FullName;
            engine.Container.AddComponent(fullName, type, type);

            Debug.WriteLine(fullName + " initialized.");
        }
Beispiel #15
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("N2: " + N2.ToString("0.0"));
            sb.AppendLine("Horas de estágio: " + HorasEstagio);
            return(base.ToString() + sb.ToString());
        }
Beispiel #16
0
 private static void UpdateRootPage(N2.Engine.IEngine engine, ContentItem imported, ContentItem startPage)
 {
     startPage.Title = imported.Title;
     startPage.Name = imported.Name;
     foreach (N2.Details.ContentDetail detail in imported.Details.Values)
         startPage[detail.Name] = detail.Value;
     engine.Persister.Save(startPage);
 }
Beispiel #17
0
        public override bool Match(N2.ContentItem item)
        {
            if (existing.ContainsKey(item.ID))
                return false;

            existing.Add(item.ID, true);
            return true;
        }
 public N2.Definitions.AllowedDefinitionResult IsAllowed(N2.Definitions.AllowedDefinitionQuery query)
 {
     if (query.ChildDefinition.ItemType.IsAssignableFrom(typeof (BlogContainer)))
     {
         return AllowedDefinitionResult.Deny;
     }
     return AllowedDefinitionResult.DontCare;
 }
		public RebuildImageSizesMigration(IPersister persister, N2.Edit.UploadFolderSource uploads, EditSection config)
		{
			this.persister = persister;
			this.uploads = uploads;
			configuredSizes = config.Images.Sizes;

			Title = "Rebuild Image Sizes";
			Description = "Redirects to a page where images can re-generated using currently configured settings";
		}
        /// <summary>
        /// Implements <see cref="N2.Plugin.IPluginInitializer.Initialize"/> to register the 
        /// instance with N2 under its full type name.
        /// </summary>
        /// <param name="engine">Specifies the <see cref="N2.Engine.IEngine"/> instance to register
        /// the plug-in with.</param>
        public virtual void Initialize(N2.Engine.IEngine engine)
        {
            Type type = this.GetType();
            string fullName = type.FullName;
            engine.Container.AddComponent(fullName, type, type);

            Debug.WriteLine(string.Format(
                "HereSay: {0} initialized.", fullName));
        }
Beispiel #21
0
 /// <summary>
 /// Returns a hash code for this instances.
 /// </summary>
 /// <returns>
 /// A hash code for this instances, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     return
         (this.HasValue.GetHashCode()
          ^ (Book == null ? 0 : Book.ToLower().GetHashCode())
          ^ (N1 == null ? 0 : N1.ToLower().GetHashCode() >> 1)
          ^ (N2 == null ? 0 : N2.ToLower().GetHashCode() << 1)
          ^ (NumberCount));
 }
Beispiel #22
0
 void Start()
 {
     SetDefault();
     N1 = Random.Range(0, 9);
     N2 = Random.Range(0, 9);
     N3 = Random.Range(0, 9);
     N4 = Random.Range(0, 9);
     Debug.Log(N1.ToString() + " " + N2.ToString() + " " + N3.ToString() + " " + N4.ToString());
 }
		public void Initialize(N2.Engine.IEngine engine)
		{
			//log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(Server.MapPath("~/N2/Installation/log4net.config")));

			RegisterControllerFactory(ControllerBuilder.Current, engine);
			RegisterRoutes(RouteTable.Routes, engine);
			RegisterViewEngines(ViewEngines.Engines);
			RegisterViewTemplates(engine);
		}
 public void Initialize(N2.Engine.IEngine engine)
 {
     // When using Dinamico check out /Dinamico/GlobalMvcStarter.cs which
     // configures these settings specifically for Dinamico
     RegisterControllerFactory(ControllerBuilder.Current, engine);
     RegisterRoutes(RouteTable.Routes, engine);
     RegisterViewEngines(ViewEngines.Engines);
     RegisterViewTemplates(engine);
 }
Beispiel #25
0
 public StringBuilder GetXml(N2.ContentItem rootItem)
 {
     StringBuilder sb = new StringBuilder();
     using (System.IO.StringWriter sw = new System.IO.StringWriter(sb))
     {
         Write(rootItem, sw);
     }
     return sb;
 }
Beispiel #26
0
        public override bool Equals(object obj)
        {
            var other = obj as SmoothTriangle;

            return(base.Equals(other) &&
                   N1.Equals(other.N1) &&
                   N2.Equals(other.N2) &&
                   N3.Equals(other.N3));
        }
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("N2: " + N2.ToString("0.0"));
            sb.AppendLine("N3: " + N3.ToString("0.0"));
            sb.AppendLine("Responsável: " + Responsavel);

            return(base.ToString() + sb.ToString());
        }
Beispiel #28
0
        public override string GetEngineValues(string format, IFormatProvider provider, string delimeter)
        {
            string buf;

            buf = N1.ToString(format, provider) + delimeter
                  + N2.ToString(format, provider) + delimeter
                  + thruster.GetThrusterValues(engineNumber, delimeter);

            return(buf);
        }
Beispiel #29
0
        //Se requiere recibir el Random para evitar la misma informacion
        public clsProceso(Random R)
        {
            decimal       N1, N2, Resultado;
            char          Signo;
            OperacionEnum Op;

            N1 = R.Next(1, 100);
            N2 = R.Next(1, 100);
            Op = (OperacionEnum)R.Next(5);

            switch (Op)
            {
            case OperacionEnum.Suma:
                Signo     = '+';
                Resultado = N1 + N2;
                break;

            case OperacionEnum.Resta:
                Signo     = '-';
                Resultado = N1 - N2;
                break;

            case OperacionEnum.Multiplicacion:
                Signo     = '*';
                Resultado = N1 * N2;
                break;

            case OperacionEnum.Division:
                Signo     = '/';
                Resultado = N1 / N2;
                break;

            case OperacionEnum.Residuo:
                Signo     = '%';
                Resultado = N1 % N2;
                break;

            default:
                Signo     = '?';
                Resultado = 0;
                break;
            }

            this.Operacion = N1.ToString() + Signo + N2.ToString();
            this.Resultado = Math.Round(Resultado, 4).ToString();
            this.TME       = this.TR = this.Servicio = R.Next(7, 18);
            this.Tamano    = R.Next(7, 30);
            this.Estado    = "Nuevo";

            this.Numero    = ++ID;
            this.Respuesta = -1;

            isCompleted = true;
        }
Beispiel #30
0
        public void Initialize(N2.Engine.IEngine engine)
        {
            if (ConfigurationManager.AppSettings["ResetData"] == "true")
            {
                ReplaceContent(engine);

                CopyFiles(engine);

                engine.Persister.ItemSaving += Persister_ItemSaving;
            }
        }
Beispiel #31
0
        protected virtual void OnWritingItem(N2.ContentItem item, XmlTextWriter xtw)
        {
            xtw.WriteStartElement("item");
            OnWritingDefaultAttributes(item, xtw);

            OnWritingAuthorizedRoles(item, xtw);
            OnWritingDetails(item, xtw);
            OnWritingDetailCollections(item, xtw);
            OnWritingChildren(item, xtw);

            xtw.WriteEndElement();
        }
        public static void ProvideRandDataSet(RichTextBox RTB)
        {
            int    N1, N2, N3, N4, N5;
            Random random = new Random();

            N1       = random.Next(0, 255);
            N2       = random.Next(0, 255);
            N3       = random.Next(0, 255);
            N4       = random.Next(0, 255);
            N5       = random.Next(0, 255);
            RTB.Text = N1.ToString() + ", " + N2.ToString() + ", " + N3.ToString() + ", " + N4.ToString() + ", " + N5.ToString();
        }
        private static void CreateDemoPanel(N2.Engine.IEngine factory, ContentItem item)
        {
            if (ConfigurationManager.AppSettings["Demo.CreateDemoPanel"] == "true")
            {
                var part = factory.Definitions.CreateInstance<Models.DemoPart>(item);
                part.ZoneName = "Right";
                part.SortOrder = -1000000;
                item.Children.Insert(0, part);

                factory.Persister.Save(part);
            }
        }
        public TemplateDefinition GetTemplate(N2.ContentItem item)
        {
            string templateName = item["TemplateName"] as string;
            if (templateName == null)
                return null;

            return GetTemplates(item.GetContentType()).Where(t => t.Name == templateName).Select(t =>
                {
                    t.Original = t.Template;
                    t.Template = () => item;
                    return t;
                }).FirstOrDefault();
        }
Beispiel #35
0
        static void Main(string[] args)
        {
            try
            {
                N2 num = new N2(2, 0);
            }
            catch (MiExcepcion e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadLine();
        }
Beispiel #36
0
        public bool PerpendicularTo(Point3d P0, Point3d P1, Point3d P2)
        {
            Vector3d V0, V1, V2, N0, N1, N2;

            V0 = P2 - P1;
            V1 = P0 - P2;
            V2 = P1 - P0;
            N0 = Vector3d.CrossProduct(V1, V2);
            if (!N0.Unitize())
            {
                return(false);
            }
            N1 = Vector3d.CrossProduct(V2, V0);
            if (!N1.Unitize())
            {
                return(false);
            }
            N2 = Vector3d.CrossProduct(V0, V1);
            if (!N2.Unitize())
            {
                return(false);
            }
            double s0 = 1.0 / V0.Length;
            double s1 = 1.0 / V1.Length;
            double s2 = 1.0 / V2.Length;
            double e0 = s0 * Math.Abs(Vector3d.DotProduct(N0, V0)) + s1 * Math.Abs(Vector3d.DotProduct(N0, V1)) + s2 * Math.Abs(Vector3d.DotProduct(N0, V2));
            double e1 = s0 * Math.Abs(Vector3d.DotProduct(N1, V0)) + s1 * Math.Abs(Vector3d.DotProduct(N1, V1)) + s2 * Math.Abs(Vector3d.DotProduct(N1, V2));
            double e2 = s0 * Math.Abs(Vector3d.DotProduct(N2, V0)) + s1 * Math.Abs(Vector3d.DotProduct(N2, V1)) + s2 * Math.Abs(Vector3d.DotProduct(N2, V2));

            if (e0 <= e1)
            {
                if (e0 <= e2)
                {
                    this = N0;
                }
                else
                {
                    this = N2;
                }
            }
            else if (e1 <= e2)
            {
                this = N1;
            }
            else
            {
                this = N2;
            }
            return(true);
        }
Beispiel #37
0
		public void Initialize(N2.Engine.IEngine factory)
		{
			if (ConfigurationManager.AppSettings["Demo.EnableContentReset"] == "true")
			{
				ReplaceContent(factory);

				if (ConfigurationManager.AppSettings["Demo.EnableUploadReset"] == "true")
				{
					CopyFiles(factory);
				}

				factory.Persister.ItemSaving += Persister_ItemSaving;
			}
		}
Beispiel #38
0
 public override IEnumerable<ContentItem> GetParts(ContentItem belowParentItem, string inZoneNamed, string filteredForInterface, N2.Web.UI.WebControls.ControlPanelState state)
 {
     var items = base.GetParts(belowParentItem, inZoneNamed, filteredForInterface, state);
     ContentItem grandParentItem = belowParentItem;
     //if (!state.IsFlagSet(ControlPanelState.DragDrop) && inZoneNamed.EndsWith("Recursive") && grandParentItem is ContentPage)
     if (inZoneNamed.EndsWith("Recursive") && grandParentItem is ContentPage)
     {
         if (!belowParentItem.VersionOf.HasValue)
             items = items.Union(GetParts(belowParentItem.Parent, inZoneNamed, filteredForInterface));
         else
             items = items.Union(GetParts(belowParentItem.VersionOf.Parent, inZoneNamed, filteredForInterface));
     }
     return items;
 }
    public override bool UpdateItem(N2.ContentItem item,Control control)
    {
        try
        {
            DropDownList ddl = (DropDownList)control;

            item[this.Name] = ddl.SelectedValue;
            return true;
        }
        catch
        {
            return false;
        }
    }
Beispiel #40
0
		public UrlParser(IPersister persister, IWebContext webContext, IHost host, N2.Plugin.ConnectionMonitor connections, HostSection config)
		{
			if (host == null) throw new ArgumentNullException("host");

			IsOnline = connections.IsConnected ?? true;
			connections.Online += (s, a) => IsOnline = true;
			connections.Offline += (s, a) => IsOnline = false;

			this.persister = persister;
			this.webContext = webContext;
			this.host = host;

			ignoreExistingFiles = config.Web.IgnoreExistingFiles;
		}
 public override bool UpdateItem(N2.ContentItem item,Control control)
 {
     try
     {
         Calendar datePicker = (Calendar)control;
         DateTime selectedDate = datePicker.SelectedDate;
         item[this.Name] = selectedDate;
         return true;
     }
     catch
     {
         return false;
     }
 }
Beispiel #42
0
        public void UpdateSuccessors(ANode <TMove> N, ANode <TMove> finalState)
        {
            // On fait appel à GetListSucc, méthode abstraite qu'on doit réécrire pour chaque
            // problème. Elle doit retourner la liste complète des noeuds successeurs de N.
            var listsucc = this.FilterNode != null?this.game.NextNodes(N, node => this.FilterNode.SameAs(node)) : this.game.NextNodes(N);

            foreach (var N2 in listsucc)
            {
                // N2 est-il une copie d'un nœud déjà vu et placé dans la liste des fermés ?
                var N2bis = graph.FindIfExistInClosed(N2);
                if (N2bis == null)
                {
                    // Rien dans les fermés. Est-il dans les ouverts ?
                    N2bis = graph.FindIfExistInOpened(N2);
                    if (N2bis != null)
                    {
                        // Il existe, donc on l'a déjà vu, N2 n'est qu'une copie de N2Bis
                        // Le nouveau chemin passant par N est-il meilleur ?
                        if (N.GCost + 1 < N2bis.GCost)
                        {
                            // Mise à jour de N2bis
                            N2bis.GCost = N.GCost + 1;
                            // HCost pas recalculé car toujours bon

                            // Mise à jour de la famille ....
                            N.Attach(N2bis, N2.MoveFromParent);

                            // Mise à jour des ouverts
                            graph.Opened.Remove(N2bis);
                            this.InsertNewNodeInOpenList(N2bis);
                        }
                        // else on ne fait rien, car le nouveau chemin est moins bon
                    }
                    else
                    {
                        // N2 est nouveau, MAJ et insertion dans les ouverts
                        N.Attach(N2, N2.MoveFromParent);

                        N2.GCost = N.GCost + 1;
                        N2.HCost = N2.Heuristics(finalState);

                        this.InsertNewNodeInOpenList(N2);
                    }

                    // Insertion pour respecter l'ordre du cout total le plus petit au plus grand
                }
                // else il est dans les fermés donc on ne fait rien,
                // car on a déjà trouvé le plus court chemin pour aller en N2
            }
        }
Beispiel #43
0
 private static void CopyFiles(N2.Engine.IEngine engine)
 {
     HttpServerUtility server = HttpContext.Current.Server;
     foreach (string folder in engine.EditManager.UploadFolders)
     {
         string upload = server.MapPath(folder);
         DeleteFilesAndFolders(upload);
     }
     File.Copy(server.MapPath("~/Addons/Demo/Resources/Sunset.jpg"), server.MapPath("~/upload/Sunset.jpg"), true);
     File.Copy(server.MapPath("~/Addons/Demo/Resources/n2.gif"), server.MapPath("~/upload/n2.gif"), true);
     File.Copy(server.MapPath("~/Addons/Demo/Resources/lav.jpg"), server.MapPath("~/upload/lav.jpg"), true);
     File.Copy(server.MapPath("~/Addons/Demo/Resources/skal.jpg"), server.MapPath("~/upload/skal.jpg"), true);
     File.Copy(server.MapPath("~/Addons/Demo/Resources/thorn.jpg"), server.MapPath("~/upload/thorn.jpg"), true);
     File.Copy(server.MapPath("~/Addons/Demo/Resources/logo_white.png"), server.MapPath("~/upload/logo_white.png"), true);
 }
        public override bool UpdateItem(N2.ContentItem item, Control editor)
        {
            ListBox lb = editor as ListBox;

            string selectedItems = string.Empty;

            foreach (ListItem listItem in lb.Items)
                if (listItem.Selected)
                    selectedItems += listItem.Value + ItemSeperator;

            selectedItems = selectedItems.TrimEnd(new char[] { ItemSeperator });

            item[this.Name] = (!string.IsNullOrEmpty(selectedItems)) ? selectedItems : null;
            return true;
        }
Beispiel #45
0
        public void Write(N2.ContentItem rootItem, System.IO.TextWriter output)
        {
            XmlTextWriter xtw = new XmlTextWriter(output);
            xtw.Formatting = this.XmlFormatting;
            xtw.WriteStartDocument();

            xtw.WriteStartElement("n2");
            xtw.WriteAttributeString("version", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            xtw.WriteAttributeString("exportVersion", "1");
            xtw.WriteAttributeString("exportDate", GetDateTimeString(N2.Utility.CurrentTime()));

            OnWritingItem(rootItem, xtw);

            xtw.WriteEndElement();
            xtw.WriteEndDocument();
        }
Beispiel #46
0
        private void MAJ_Successeurs(Noeuds N)
        {
            // On fait appel à GetListSucc, méthode abstraite qu'on doit réécrire pour chaque
            // problème. Elle doit retourner la liste complète des noeuds successeurs de N.
            List <Noeuds> listsucc = N.ListeSuccesseur();

            foreach (Noeuds N2 in listsucc)
            {
                // N2 est-il une copie d'un nœud déjà vu et placé dans la liste des fermés ?
                Noeuds N2bis = ChercheNoeudDansFermes(N2);
                if (N2bis == null)
                {
                    // Rien dans les fermés. Est-il dans les fermes ?
                    N2bis = ChercheNoeudDansOuverts(N2);
                    if (N2bis != null)
                    {
                        // Il existe, donc on l'a déjà vu, N2 n'est qu'une copie de N2Bis
                        // Le nouveau chemin passant par N est-il meilleur ?
                        if (N.CoutDepuisInit + N.CoutDeArcAvec(N2) < N2bis.CoutDepuisInit)
                        {
                            // Mise à jour de N2bis
                            N2bis.CoutDepuisInit += N.CoutDeArcAvec(N2);
                            // HCost pas recalculé car toujours bon
                            N2bis.calculCoutTotal(); // somme de GCost et HCost
                            // Mise à jour de la famille ....
                            N2bis.Supprime_Liens_Parent();
                            N2bis.Definir_Comme_Parent(N);
                            // Mise à jour des fermes
                            L_Ouverts.Remove(N2bis);
                            this.AjoutAuxOuverts(N2bis);
                        }
                        // else on ne fait rien, car le nouveau chemin est moins bon
                    }
                    else
                    {
                        // N2 est nouveau, MAJ et insertion dans les fermes
                        N2.CoutDepuisInit += N.CoutDeArcAvec(N2);
                        N2.CalculerCoutVersNoeudFinal();
                        N2.Definir_Comme_Parent(N);
                        N2.calculCoutTotal(); // somme de GCost et HCost
                        this.AjoutAuxOuverts(N2);
                    }
                }
                // else il est dans les fermés donc on ne fait rien,
                // car on a déjà trouvé le plus court chemin pour aller en N2
            }
        }
 public override bool Equals(object obj)
 {
     return(obj is Triangle triangle &&
            Transform.Equals(triangle.Transform) &&
            Material.Equals(triangle.Material) &&
            Parent == triangle.Parent &&
            HasParent == triangle.HasParent &&
            P1.Equals(triangle.P1) &&
            P2.Equals(triangle.P2) &&
            P3.Equals(triangle.P3) &&
            Edge1.Equals(triangle.Edge1) &&
            Edge2.Equals(triangle.Edge2) &&
            Normal.Equals(triangle.Normal) &&
            N1.Equals(triangle.N1) &&
            N2.Equals(triangle.N2) &&
            N3.Equals(triangle.N3) &&
            IsSmoothed == triangle.IsSmoothed);
 }
        public override int GetHashCode()
        {
            int hashCode = -2063967696;

            hashCode = hashCode * -1521134295 + Transform.GetHashCode();
            hashCode = hashCode * -1521134295 + Material.GetHashCode();
            hashCode = hashCode * -1521134295 + SavedRay.GetHashCode();
            hashCode = hashCode * -1521134295 + Parent.GetHashCode();
            hashCode = hashCode * -1521134295 + HasParent.GetHashCode();
            hashCode = hashCode * -1521134295 + P1.GetHashCode();
            hashCode = hashCode * -1521134295 + P2.GetHashCode();
            hashCode = hashCode * -1521134295 + P3.GetHashCode();
            hashCode = hashCode * -1521134295 + Edge1.GetHashCode();
            hashCode = hashCode * -1521134295 + Edge2.GetHashCode();
            hashCode = hashCode * -1521134295 + Normal.GetHashCode();
            hashCode = hashCode * -1521134295 + N1.GetHashCode();
            hashCode = hashCode * -1521134295 + N2.GetHashCode();
            hashCode = hashCode * -1521134295 + N3.GetHashCode();
            hashCode = hashCode * -1521134295 + IsSmoothed.GetHashCode();
            return(hashCode);
        }
Beispiel #49
0
        /// <summary>
        /// Finalize edge marking
        /// </summary>
        public void MarkNeighborEdges()
        {
            //for (int i = 0; i < 3; i++)
            //{
            //    if (EdgeIsConstrained[i] && Neighbors[i] != null)
            //    {
            //        Neighbors[i].MarkConstrainedEdge(Points[(i + 1) % 3], Points[(i + 2) % 3]);
            //    }

            //}

            //-----------------
            //0
            if (this.C0 && N0 != null)
            {
                //(0 + 1) % 3 => 2
                //(0 + 2) % 3 => 1
                N0.SelectAndMarkConstrainedEdge(2, 1);
            }
            //-----------------
            //1
            if (this.C1 && N1 != null)
            {
                //(1 + 1) % 3 => 1
                //(1 + 2) % 3 => 0
                N1.SelectAndMarkConstrainedEdge(1, 0);
            }
            //-----------------
            //2
            if (this.C2 && N2 != null)
            {
                //(2 + 1) % 3 => 0
                //(2 + 2) % 3 => 1

                N2.SelectAndMarkConstrainedEdge(0, 1);
            }
        }
Beispiel #50
0
 public int GetInt()
 {
     return(int.Parse(N1.ToString() + "" + N2.ToString() + "" + N3.ToString() + "" + N4.ToString()));
 }
Beispiel #51
0
        public void TestMatricesFromNoisedPoints()
        {
            List <Image <Arthmetic, double> > ptsReal = new List <Image <Arthmetic, double> >();
            List <PointF> pts1    = new List <PointF>();
            List <PointF> pts2    = new List <PointF>();
            List <PointF> pts3    = new List <PointF>();
            List <PointF> pts1Ref = new List <PointF>();
            List <PointF> pts2Ref = new List <PointF>();
            List <PointF> pts3Ref = new List <PointF>();

            Random rand        = new Random(1003);
            double stddev      = 3;
            int    pointsCount = 100;

            for (int i = 0; i < pointsCount; ++i)
            {
                var real = new Image <Arthmetic, double>(new double[, , ] {
                    { { rand.Next(100, 200) } },
                    { { rand.Next(100, 200) } },
                    { { rand.Next(50, 100) } },
                    { { 1 } },
                });

                ptsReal.Add(real);
                var i1 = P1.Multiply(real).ToPointF();
                pts1Ref.Add(i1);
                i1 = new PointF(i1.X + Noise(stddev, rand), i1.Y + Noise(stddev, rand));
                pts1.Add(i1);

                var i2 = P2.Multiply(real).ToPointF();
                pts2Ref.Add(i2);
                i2 = new PointF(i2.X + Noise(stddev, rand), i2.Y + Noise(stddev, rand));
                pts2.Add(i2);

                var i3 = P3.Multiply(real).ToPointF();
                pts3Ref.Add(i3);
                i3 = new PointF(i3.X + Noise(stddev, rand), i3.Y + Noise(stddev, rand));
                pts3.Add(i3);
            }

            double rangeLx = pts1.Max((x) => x.X) - pts1.Min((x) => x.X);
            double rangeLy = pts1.Max((x) => x.Y) - pts1.Min((x) => x.Y);
            double rangeRx = pts2.Max((x) => x.X) - pts2.Min((x) => x.X);
            double rangeRy = pts2.Max((x) => x.Y) - pts2.Min((x) => x.Y);

            var pts1_n = new List <PointF>(pts1);
            var pts2_n = new List <PointF>(pts2);
            var pts3_n = new List <PointF>(pts3);

            FindTransformation.NormalizePoints2d(pts1_n, out Image <Arthmetic, double> N1);
            FindTransformation.NormalizePoints2d(pts2_n, out Image <Arthmetic, double> N2);
            FindTransformation.NormalizePoints2d(pts3_n, out Image <Arthmetic, double> N3);

            var F   = ComputeMatrix.F(new VectorOfPointF(pts1_n.ToArray()), new VectorOfPointF(pts2_n.ToArray()));
            var F23 = ComputeMatrix.F(new VectorOfPointF(pts2_n.ToArray()), new VectorOfPointF(pts3_n.ToArray()));

            // F is normalized - lets denormalize it
            F   = N2.T().Multiply(F).Multiply(N1);
            F23 = N3.T().Multiply(F23).Multiply(N2);

            var E   = ComputeMatrix.E(F, K);
            var E23 = ComputeMatrix.E(F23, K);

            var svd   = new Svd(E);
            var svd23 = new Svd(E23);

            FindTransformation.DecomposeToRTAndTriangulate(pts1, pts2, K, E, out var RR, out var TT, out Image <Arthmetic, double> estReal_);
            FindTransformation.DecomposeToRTAndTriangulate(pts2, pts3, K, E23, out var RR23, out var TT23, out Image <Arthmetic, double> estReal23_);

            var rr0 = RotationConverter.MatrixToEulerXYZ(R12);
            var rr1 = RotationConverter.MatrixToEulerXYZ(RR);

            double idealScale  = T23.Norm / T12.Norm;
            double idealScale2 = T12.Norm / T23.Norm;

            var tt0    = T12.Mul(1 / T12.Norm);
            var tt1    = TT.Mul(1 / TT.Norm).Mul(T12[0, 0] * TT[0, 0] < 0 ? -1 : 1);
            var tt1_23 = TT23.Mul(1 / TT23.Norm).Mul(T23[0, 0] * TT23[0, 0] < 0 ? -1 : 1);

            FindTransformation.TriangulateChieral(pts1, pts2, K, RR, tt1, out var estReal12);
            FindTransformation.TriangulateChieral(pts2, pts3, K, RR23, tt1_23, out var estReal23);

            RansacScaleEstimation ransacModel = new RansacScaleEstimation(estReal12, estReal23, RR, ComputeMatrix.Center(tt1, RR));

            int    sampleSize       = (int)(0.1 * pointsCount);
            int    minGoodPoints    = (int)(0.2 * pointsCount);
            int    maxIterations    = 1000;
            double meanRefPointSize = ScaleBy3dPointsMatch.GetMeanSize(estReal12);
            double threshold        = meanRefPointSize * meanRefPointSize * 0.1;
            var    result           = RANSAC.ProcessMostInliers(ransacModel, maxIterations, sampleSize, minGoodPoints, threshold, 1.0);
            double scale            = (double)result.BestModel;

            var estRealRef23To12 = ScaleBy3dPointsMatch.TransfromBack3dPoints(RR, tt1, estReal23, scale);

            double simpleScaleMean = 0.0;

            for (int i = 0; i < pointsCount; ++i)
            {
                var p12 = new Image <Arthmetic, double>(new double[, , ] {
                    { { estReal12[1, i] } },
                    { { estReal12[2, i] } },
                    { { estReal12[3, i] } },
                });
                var p23 = new Image <Arthmetic, double>(new double[, , ] {
                    { { estReal23[0, i] } },
                    { { estReal23[1, i] } },
                    { { estReal23[2, i] } },
                });

                double n1          = p12.Norm;
                double n2          = p23.Norm;
                double simpleScale = n2 / n1;
                simpleScaleMean += simpleScale;
            }

            simpleScaleMean /= pointsCount;
            double simpleScaleMean2 = 1 / simpleScaleMean;

            // TODO: compute below only on inliers
            Image <Arthmetic, double> inliersOnly12    = new Image <Arthmetic, double>(result.Inliers.Count, 4);
            Image <Arthmetic, double> inliersOnly12Ref = new Image <Arthmetic, double>(result.Inliers.Count, 4);
            Image <Arthmetic, double> inliersOnly23    = new Image <Arthmetic, double>(result.Inliers.Count, 4);

            for (int i = 0; i < result.Inliers.Count; ++i)
            {
                int k = result.Inliers[i];
                for (int j = 0; j < 4; ++j)
                {
                    inliersOnly12[j, i]    = estReal12[j, k];
                    inliersOnly12Ref[j, i] = ptsReal[k][j, 0];
                    inliersOnly23[j, i]    = estRealRef23To12[j, k];
                }
            }


            var ptsRealM = Utils.Matrixify(ptsReal);

            Errors.TraingulationError(ptsRealM, estReal12, out double mean1x, out double median1x, out List <double> errors1x);
            Errors.TraingulationError(ptsRealM, estRealRef23To12, out double mean1z, out double median1z, out List <double> errors1z);

            Errors.TraingulationError(inliersOnly12Ref, inliersOnly12, out double mean_in1, out double median_in1, out List <double> errors_in1);
            Errors.TraingulationError(inliersOnly12Ref, inliersOnly23, out double mean_in2, out double median_in2, out List <double> errors_in2);
            Errors.TraingulationError(inliersOnly12, inliersOnly23, out double mean_in3, out double median_in3, out List <double> errors_in3);

            var ptsReal23M = ForwardProject3dPoints(ptsRealM, R12, C2);

            Errors.TraingulationError(ptsReal23M, estReal23, out double mean1h, out double median1h, out List <double> errors1h);

            var estC2     = ComputeMatrix.Center(tt1, RR);
            var ptsEst23M = ForwardProject3dPoints(estReal12, RR, estC2);

            Errors.TraingulationError(ptsEst23M, estReal23, out double mean1t, out double median1t, out List <double> errors1t);

            int dummy = 0;

            //Errors.TraingulationError(ptsReal, estReal, out double mean1, out double median1, out List<double> errors1);
            //Errors.ReprojectionError(estReal, pts2, K, RR, tt1, out double mean_r1a, out double median_r1a, out List<double> _1);
            //Errors.ReprojectionError(estReal, pts2Ref, K, RR, tt1, out double mean_r1b, out double median_r1b, out List<double> _2);
            //Errors.ReprojectionError(estReal, pts2Ref, K, R12, tt0, out double mean_r1c, out double median_r1c, out List<double> _3);
            //Errors.ReprojectionError(Errors.Matrixify(ptsReal), pts2Ref, K, RR, tt1, out double mean_r1e, out double median_r1e, out List<double> _5);

            var H1   = FindTransformation.EstimateHomography(pts1, pts2, K);
            var H2   = FindTransformation.EstimateHomography(pts1Ref, pts2Ref, K);
            var hrr1 = RotationConverter.MatrixToEulerXYZ(H1);
            var hrr2 = RotationConverter.MatrixToEulerXYZ(H2);
            //var zeroT = new Image<Arthmetic, double>(1, 3);

            //var H3 = RotationConverter.EulerXYZToMatrix(hrr1);
            //var hrr3 = RotationConverter.MatrixToEulerXYZ(H1);

            //var svdH = new Svd(H1);

            bool isRotation = FindTransformation.IsPureRotation(H1);

            int dummy2 = 0;

            //Errors.ReprojectionError2d(pts1Ref, pts2Ref, K, H2, out double mean_h2, out double median_h2, out var err_h2);
            //Errors.ReprojectionError2d(pts1, pts2, K, H1, out double mean_h1, out double median_h1, out var err_h1);
            //Errors.ReprojectionError2d(pts1, pts2, K, H3, out double mean_h3, out double median_h3, out var err_h3);

            //Errors.ReprojectionError2dWithT(pts1, pts2, K, H1, zeroT, out double scale1, out double mean_h1a, out double median_h1a, out var err_h1a);
            //Errors.ReprojectionError2dWithT(pts1, pts2, K, H3, zeroT, out double scale1x, out double mean_h1ax, out double median_h1ax, out var err_h1ax);
            ////  Errors.ReprojectionError2dWithT(pts1, pts2, K, R12, tt0, out double scale2, out double mean_h1b, out double median_h1b, out var err_h1b);
            //Errors.ReprojectionError2dWithT(pts1, pts2, K, RR, tt1, out double scale3, out double mean_h1c, out double median_h1c, out var err_h1c);
            //Errors.ReprojectionError2dWithT(pts1, pts2, K, R12, tt1, out double scale5, out double mean_h1c1, out double median_h1c1, out var err_h1c1);
            //Errors.ReprojectionError2dWithT(pts1Ref, pts2Ref, K, R12, tt0, out double scale6, out double mean_h1c2, out double median_h1c2, out var err_h1c2);
            //Errors.ReprojectionError2dWithT(pts1, pts2, K, H1, tt1, out double scale4, out double mean_h1d, out double median_h1d, out var err_h1d);

            //var KK = EstimateCameraFromImagePair.K(F, 600, 500);
            //var EE = ComputeMatrix.E(F, KK);
            //var svd2 = new Svd(EE);

            //FindTransformation.DecomposeToRTAndTriangulate(pts1, pts2, KK, EE, out var RR2, out var TT2, out Image<Arthmetic, double> estReal2);
            //var tt2 = TT2.Mul(1 / TT2.Norm);
            //var rr2 = RotationConverter.MatrixToEulerXYZ(RR2);

            //Errors.TraingulationError(ptsReal, estReal2, out double mean2, out double median2, out List<double> errors2);
            //Errors.ReprojectionError(estReal2, pts2, KK, RR2, tt2, out double mean_r2a, out double median_r2a, out List<double> _1x);
            //Errors.ReprojectionError(estReal2, pts2Ref, KK, RR2, tt2, out double mean_r2b, out double median_r2b, out List<double> _2x);
            //Errors.ReprojectionError(estReal2, pts2Ref, KK, R12, tt0, out double mean_r2c, out double median_r2c, out List<double> _3x);
            //Errors.ReprojectionError(Errors.Matrixify(ptsReal), pts2Ref, KK, RR2, tt2, out double mean_r2e, out double median_r2e, out List<double> _5x);
        }
        /// <summary>
        /// 改变数字
        /// </summary>
        /// <param name="num">数字</param>
        public void ChangeNum(double num)
        {
            if (num >= 0 && !IsPostive)
            {
                PostiveAndNegativeChanged?.Invoke(this, new PostiveAndNegativeChangedEventArgs {
                    OldValue = IsPostive, NewValue = true
                });
                IsPostive = true;
            }
            else if (num < 0 && IsPostive)
            {
                PostiveAndNegativeChanged?.Invoke(this, new PostiveAndNegativeChangedEventArgs {
                    OldValue = IsPostive, NewValue = false
                });
                IsPostive = false;
            }
            num = Math.Abs(num);
            string numstr = num.ToString();

            if (numstr.IndexOf("E+") >= 0)
            {
                string[] numstmp = Regex.Split(numstr, "E+");
                numstr = numstmp[0];
                int x = 1;
                if (numstmp[0].IndexOf(".") >= 0)
                {
                    numstr = numstr.Replace(".", "");
                    x      = numstmp[0].Length - numstmp[0].IndexOf(".");
                }
                for (int i = x - 1; i < int.Parse(numstmp[1]); i++)
                {
                    numstr += "0";
                }
            }
            int[] numids = new int[6];
            if (num >= 10000)
            {
                if (num >= 100000000)
                {
                    string tmp1 = numstr.Split('.')[0];
                    string tmp2 = tmp1.Substring(0, tmp1.Length - 8); //整数部分
                    string tmp3 = tmp1.Substring(tmp2.Length, 1);     //小数部分

                    numids[5] = -2;
                    numids[4] = int.Parse(tmp1.Substring(tmp2.Length + 1, 1)) >= 5 ? int.Parse(tmp3) + 1 : int.Parse(tmp3);

                    if (numids[4] >= 10)
                    {
                        numids[4] -= 10;
                        tmp2       = (int.Parse(tmp2) + 1).ToString();
                    }

                    for (int i = 1; i <= 4; i++)
                    {
                        if (tmp2.Length - i >= 0)
                        {
                            numids[4 - i] = int.Parse(tmp2.Substring(tmp2.Length - i, 1));
                        }
                        else
                        {
                            if (4 - i == 3)
                            {
                                numids[3] = 0;
                            }
                            else
                            {
                                numids[4 - i] = -3;
                            }
                        }
                    }
                }
                else
                {
                    string tmp1 = numstr.Split('.')[0];
                    string tmp2 = tmp1.Substring(0, tmp1.Length - 4); //整数部分
                    string tmp3 = tmp1.Substring(tmp2.Length, 1);     //小数部分

                    numids[5] = -1;
                    numids[4] = int.Parse(tmp1.Substring(tmp2.Length + 1, 1)) >= 5 ? int.Parse(tmp3) + 1 : int.Parse(tmp3);

                    if (numids[4] >= 10)
                    {
                        numids[4] -= 10;
                        tmp2       = (int.Parse(tmp2) + 1).ToString();
                    }

                    for (int i = 1; i <= 4; i++)
                    {
                        if (tmp2.Length - i >= 0)
                        {
                            numids[4 - i] = int.Parse(tmp2.Substring(tmp2.Length - i, 1));
                        }
                        else
                        {
                            numids[4 - i] = -3;
                        }
                    }
                }
            }
            else
            {
                string[] tmp1 = numstr.Split('.');
                for (int i = 1; i <= 4; i++)
                {
                    if (tmp1[0].Length - i >= 0)
                    {
                        numids[4 - i] = int.Parse(tmp1[0].Substring(tmp1[0].Length - i, 1));
                    }
                    else
                    {
                        numids[4 - i] = -3;
                    }
                }
                if (tmp1.Length > 1)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        if (tmp1[1].Length - i > 0)
                        {
                            numids[4 + i] = int.Parse(tmp1[1].Substring(i, 1));
                        }
                        else
                        {
                            numids[4 + i] = 0;
                        }
                    }
                }
            }
            N4.ChangeNum(numids[0]);
            N3.ChangeNum(numids[1]);
            N2.ChangeNum(numids[2]);
            N1.ChangeNum(numids[3]);
            if (numids[4] == 0 && numids[5] == 0)
            {
                numpoint.Visibility = Visibility.Hidden;
                P1.Visibility       = Visibility.Hidden;
                P2.Visibility       = Visibility.Hidden;
                ViewPanel.Margin    = new Thickness(30, 0, -28, 0);
            }
            else
            {
                numpoint.Visibility = Visibility.Visible;
                P1.Visibility       = Visibility.Visible;
                P2.Visibility       = Visibility.Visible;
                ViewPanel.Margin    = new Thickness(1, 0, 1, 0);
                P1.ChangeNum(numids[4]);
                P2.ChangeNum(numids[5]);
            }
        }
Beispiel #53
0
        /// <summary>
        /// overrides the <see cref="CustomEntity.OnDraw(OpenGlDevice)"/> method.
        /// </summary>
        /// <param name="Device"></param>
        protected override void OnDraw(OpenGlDevice Device)
        {
            base.OnDraw(Device);
            if (Transverse == null)
            {
                return;
            }
            if (Transverse.Count == 0)
            {
                return;
            }

            for (int i = 1; i > 0; i--)
            {
                if (Trace[i].dist(Trace[i - 1]) < Utils.epsilon)
                {
                    Trace.RemoveAt(i);
                }
            }
            if ((Trace.Count == 3) && (Trace.Closed()))
            {
                Trace.RemoveAt(2);
            }
            if (Trace.Count <= 1)
            {
                return;
            }
            //    if (Trace.Count <= 1) return;
            xyz Basey = new xyz(0, 0, 0);

            if (Trace.Count == 2)
            {
                Basey = new xyz(0, 0, -1);
                if ((Basey & (Trace[1] - Trace[0])).length() < 0.000001)
                {
                    Basey = new xyz(0, -1, 0);
                }
            }
            else
            {
                Basey = (((Trace[2] - Trace[1]) & (Trace[0] - Trace[1]))).normalized() * (-1);
            }

            for (int i = 0; i < Trace.Count - 1; i++)
            {
                xyz N1, N2;
                if (i == 0)
                {
                    if (Trace.Closed())
                    {
                        N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[Trace.Count - 2] - Trace[i]).normalized();
                    }
                    else
                    {
                        N1 = (Trace[i + 1] - Trace[i]).normalized();
                    }

                    if ((i + 2) == Trace.Count)
                    {
                        N2 = (Trace[i] - Trace[i + 1]).normalized() & Basey;
                    }
                    else
                    {
                        N2 = (Trace[i] - Trace[i + 1]).normalized() - (Trace[i + 2] - Trace[i + 1]).normalized();
                    }
                }
                else
                if (i == (Trace.Count - 2))
                {
                    N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[i - 1] - Trace[i]).normalized();
                    if (Trace.Closed())
                    {
                        N2 = (Trace[i] - Trace[0]).normalized() - (Trace[1] - Trace[0]).normalized();
                    }
                    else
                    {
                        N2 = (Trace[i] - Trace[Trace.Count - 1]).normalized();
                    }
                }
                else
                {
                    N1 = (Trace[i + 1] - Trace[i]).normalized() - (Trace[i - 1] - Trace[i]).normalized();
                    N2 = (Trace[i] - Trace[i + 1]).normalized() - (Trace[i + 2] - Trace[i + 1]).normalized();
                }
                if (Trace.Count == 2)
                {
                    N1 = Trace[1] - Trace[0];
                    N2 = Trace[0] - Trace[1];
                }
                Plane P1 = new Plane(Trace[i], N1.normalized());
                Plane P2 = new Plane(Trace[i + 1], N2.normalized());

                if (i > 0)
                {
                    Basey = Matrix.Mirror(P1) * Basey - Matrix.Mirror(P1) * new xyz(0, 0, 0);
                }
                Base B = new Base();
                B.BaseO = Trace[i];
                B.BaseZ = (Trace[i + 1] - Trace[i]).normalized();
                B.BaseY = Basey.normalized();
                B.BaseX = (B.BaseY & B.BaseZ).normalized();
                B.BaseY = B.BaseZ & B.BaseX * (-1);



                Matrix BInvert   = B.ToMatrix().invert();
                Plane  DownPlane = BInvert * P1;
                Plane  UpPlane   = BInvert * P2;
                Device.PushMatrix();
                Device.MulMatrix(B.ToMatrix());
                for (int m = 0; m < Transverse.Count; m++)
                {
                    for (int n = 0; n < Transverse[m].Count; n++)
                    {
                        CurveExtruder CE = new CurveExtruder();
                        CE.Height = -1;


                        CE.DownPlane = BInvert * P1;
                        CE.UpPlane   = BInvert * P2;
                        CE.Curve     = Transverse[m][n];
                        CE.Paint(Device);
                        if (Device.RenderKind == RenderKind.SnapBuffer)
                        {
                            SnappItem SI = Selector.StoredSnapItems[Selector.StoredSnapItems.Count - 1];
                            if (SI != null)
                            {
                                SI.OfObject = this;
                            }
                        }
                    }
                }

                double L = (Trace[i + 1] - Trace[i]).length();

                if ((i == 0) && (CloseFirst))
                {
                    Device.drawPolyPolyCurve(Transverse);
                }
                if ((i == Trace.Count - 2) && (CloseLast))
                {
                    Device.PushMatrix();
                    Device.MulMatrix(Matrix.Translation(new xyz(0, 0, L)));
                    Device.drawPolyPolyCurve(Transverse);
                    Device.PopMatrix();
                }
                Device.PopMatrix();
            }
        }
Beispiel #54
0
 public void TestConstructorN2()
 {
     N2 a = new N2(2, 0);
 }
Beispiel #55
0
 public string GetString()
 {
     return(N1.ToString() + "" + N2.ToString() + "" + N3.ToString() + "" + N4.ToString());
 }
Beispiel #56
0
        /// <summary>
        /// Build purchase order.
        /// Original example from http://www.x12.org/examples/004010X357/tax-exempt-purchase-order/
        /// </summary>
        public static TS850 BuildPurchaseOrder(string controlNumber)
        {
            var result = new TS850();

            //  Indicates the start of a purchase order transaction set and assigns a control number.
            result.ST = new ST();
            result.ST.TransactionSetIdentifierCode_01 = "850";
            result.ST.TransactionSetControlNumber_02  = controlNumber.PadLeft(9, '0');

            //  Indicates that this is original purchase order number XX-1234, dated March 1, 2017, and that no acknowledgment is necessary.
            result.BEG = new BEG();
            result.BEG.TransactionSetPurposeCode_01 = "00";
            result.BEG.PurchaseOrderTypeCode_02     = "SA";
            result.BEG.PurchaseOrderNumber_03       = "XX-1234";
            result.BEG.Date_05 = "20170301";
            result.BEG.AcknowledgmentType_07 = "NA";

            //  Repeating PER
            result.PER = new List <PER>();

            //  Indicates that the name of the Buyer is Ed Smith, and his telephone number is (800) 123-4567.
            var per = new PER();

            per.ContactFunctionCode_01 = "BD";
            per.Name_02 = "ED SMITH";
            per.CommunicationNumberQualifier_03 = "TE";
            per.CommunicationNumber_04          = "8001234567";
            result.PER.Add(per);

            //  Repeating TAX
            result.TAX = new List <TAX>();

            //  Provides state tax exempt ID 53247765.
            var tax = new TAX();

            tax.TaxIdentificationNumber_01 = "53247765";
            tax.LocationQualifier_02       = "SP";
            tax.LocationIdentifier_03      = "CA";
            tax.TaxExemptCode_12           = "9";
            result.TAX.Add(tax);

            //  Repeating N1 Loops
            result.N1Loop = new List <Loop_N1_850>();

            //  Begin N1 Loop
            var n1Loop = new Loop_N1_850();

            //  Indicates that the buyer is ABC Aerospace. ABC's D-U-N-S+4 number is 123456789-0101.
            n1Loop.N1 = new N1();
            n1Loop.N1.EntityIdentifierCode_01 = "BY";
            n1Loop.N1.Name_02 = "ABC AEROSPACE";
            n1Loop.N1.IdentificationCodeQualifier_03 = "9";
            n1Loop.N1.IdentificationCode_04          = "1234567890101";

            //  Repeating N2
            n1Loop.N2 = new List <N2>();

            //  Provides additional name content for the buyer.
            var n2 = new N2();

            n2.Name_01 = "AIRCRAFT DIVISION";
            n1Loop.N2.Add(n2);

            //  Repeating N3
            n1Loop.N3 = new List <N3>();

            //  The buyer’s street address is 2000 Jet Blvd.
            var n3 = new N3();

            n3.AddressInformation_01 = "2000 JET BLVD";
            n1Loop.N3.Add(n3);

            //  Repeating N4
            n1Loop.N4 = new List <N4>();

            //  The buyer’s city, state, and ZIP is Fighter Town, CA 98898.
            var n4 = new N4();

            n4.CityName_01            = "FIGHTER TOWN";
            n4.StateorProvinceCode_02 = "CA";
            n4.PostalCode_03          = "98898";
            n1Loop.N4.Add(n4);

            //  End N1 Loop
            result.N1Loop.Add(n1Loop);

            //  Repeating PO1 Loops
            result.PO1Loop = new List <Loop_PO1_850>();

            //  Begin PO1 Loop
            var pO1Loop = new Loop_PO1_850();

            //  Indicates Baseline item 1 is a request to purchase 25 units, with a price of $36.00 each, of manufacturer's part number XYZ-1234.
            pO1Loop.PO1 = new PO1();
            pO1Loop.PO1.AssignedIdentification_01        = "1";
            pO1Loop.PO1.QuantityOrdered_02               = "25";
            pO1Loop.PO1.UnitorBasisforMeasurementCode_03 = "EA";
            pO1Loop.PO1.UnitPrice_04                 = "36";
            pO1Loop.PO1.BasisofUnitPriceCode_05      = "PE";
            pO1Loop.PO1.ProductServiceIDQualifier_06 = "MG";
            pO1Loop.PO1.ProductServiceID_07          = "XYZ-1234";

            //  Repeating MEA
            pO1Loop.MEA = new List <MEA>();

            //  Indicates that each unit in the order weighs 10 ounces.
            var mea = new MEA();

            mea.MeasurementReferenceIDCode_01 = "WT";
            mea.MeasurementQualifier_02       = "WT";
            mea.MeasurementValue_03           = "10";
            mea.CompositeUnitofMeasure_04     = new C001();
            mea.CompositeUnitofMeasure_04.UnitorBasisforMeasurementCode_01 = "OZ";
            pO1Loop.MEA.Add(mea);

            //  Indicates that no product substitution is allowed.
            pO1Loop.IT8 = new IT8();
            pO1Loop.IT8.ProductServiceSubstitutionCode_07 = "B0";

            //  Repeating SCH Loops
            pO1Loop.SCHLoop = new List <Loop_SCH_850>();

            //  Begin SCH Loop
            var schLoop = new Loop_SCH_850();

            //  Indicates that the 25 units are required to arrive by June 15, 2017.
            schLoop.SCH             = new SCH();
            schLoop.SCH.Quantity_01 = "25";
            schLoop.SCH.UnitorBasisforMeasurementCode_02 = "EA";
            schLoop.SCH.DateTimeQualifier_05             = "106";
            schLoop.SCH.Date_06 = "20170615";

            //  End SCH Loop
            pO1Loop.SCHLoop.Add(schLoop);

            //  End PO1 Loop
            result.PO1Loop.Add(pO1Loop);

            //  Begin CTT Loop
            result.CTTLoop = new Loop_CTT_850();

            //  Indicates that the purchase order contains 1 line item.
            result.CTTLoop.CTT = new CTT();
            result.CTTLoop.CTT.NumberofLineItems_01 = "1";

            //  Indicates that the total amount of the purchase order is $900.
            result.CTTLoop.AMT = new AMT();
            result.CTTLoop.AMT.AmountQualifierCode_01 = "TT";
            result.CTTLoop.AMT.MonetaryAmount_02      = "900";

            //  End CTT Loop

            return(result);
        }
        void pruebaCorridas(List <double> Xi)
        {
            int         R, N1, N2;
            double      Media, Desviacion, H, Z0;
            List <bool> Arriba = new List <bool>();

            // Ver si estan arriba o abajo
            foreach (double x in Xi)
            {
                if (x < 0.5)
                {
                    Arriba.Add(false);
                }
                else
                {
                    Arriba.Add(true);
                }
            }

            R  = numDeCorridas(Arriba);
            N1 = Arriba.FindAll(x => x == false).Count;
            N2 = Arriba.FindAll(x => x == true).Count;

            // Calcular media
            Media = 2 * N1 * N2;
            Media = Media / (N1 + N2);
            Media = Media + 1;

            // Calcular desviacion
            Desviacion = (2 * N1 * N2) - N1 - N2;
            Desviacion = 2 * N1 * N2 * Desviacion;
            Desviacion = Desviacion / (Math.Pow(N1 + N2, 2) * (N1 + N2 - 1));
            Desviacion = Math.Sqrt(Desviacion);

            // Corrección para continuidad
            H = R < Media ? 0.5 : -0.5;

            // Valor estadístico Z0
            Z0 = R + H - Media;
            Z0 = Z0 / Desviacion;

            lblR.Text          = "R = " + R.ToString();
            lblN1.Text         = "N1 = " + N1.ToString();
            lblN2.Text         = "N2 = " + N2.ToString();
            lblMedia.Text      = "Media = " + Media.ToString();
            lblDesviacion.Text = "Desviacion = " + Desviacion.ToString();
            lblH.Text          = "H = " + H.ToString();
            lblZ.Text          = "Z0 = " + Z0.ToString();

            if (Z0 < -1.96)
            {
                lblResultado.Text = "Resultado\nZ0 < -1.96\n∴\nNo se comportan de manera aleatoria.";
            }
            else if (Z0 > 1.96)
            {
                lblResultado.Text = "Resultado\n1.96 < Z0\n∴\nNo se comportan de manera aleatoria.";
            }
            else
            {
                lblResultado.Text = "Resultado\n-1.96 ≤ Z0 ≤ 1.96\n∴\nSe comportan de manera aleatoria.";
            }
        }