예제 #1
0
파일: TabTree.cs 프로젝트: GabeTesta/Warps
        /// <summary>
        /// this function is going to check whether the target position index is smaller 
        /// than the smallest child index in the tree. 
        /// </summary>
        /// <param name="parents">dragged item parents</param>
        /// <param name="trgt">target IRebuild</param>
        /// <param name="aboveMe">the child that is lower than the target if there is one</param>
        /// <returns>true if index is beneath dependents, false otherwise</returns>
        private bool CheckWaterMarkIndexChildren(List<IRebuild> children, IRebuild trgt, ref IRebuild belowMe)
        {
            if (children.Contains(trgt))
                return false;

            TreeNode target = FindNode(trgt);
            int tarDepth = 0;
            TheIndexOf(trgt, null, ref tarDepth);

            foreach (IRebuild irb in children)
            {
                //if((irb is IGroup)
                TreeNode child = FindNode(irb);
                int childDepth = 0;
                TheIndexOf(irb, null, ref childDepth);
                if (trgt is IGroup) // if the target is a group that contains a child, return false because we want to insert
                    if ((trgt as IGroup).FindItem(irb) != null)
                    {
                        belowMe = irb;
                        return false;
                    }

                if (tarDepth > childDepth)
                {
                    belowMe = irb;
                    return false;//if the target depth
                }
                // is more than the child depth, then don't allow
            }

            return true;
        }
예제 #2
0
파일: Sail.cs 프로젝트: GabeTesta/Warps
 internal void Remove(IRebuild tag)
 {
     if (tag is IGroup)
     {
         IGroup g = FindGroup(tag.Label);
         Layout.Remove(g);
     }
 }
예제 #3
0
 public bool Rebuild(IRebuild tag)
 {
     if (tag != null)
         tag.Update(ActiveSail);
     if (AutoBuild)
     {
         //List<IRebuild> updated = ActiveSail.Rebuild(tag);
         List<IRebuild> connected = ActiveSail.GetConnected(tag);
         List<IRebuild> succeeded = new List<IRebuild>();
         List<IRebuild> failed = new List<IRebuild>();
         DateTime before = DateTime.Now;
         if (connected != null)
         {
             foreach (IRebuild item in connected)
             {
                 if (item.Update(ActiveSail))
                     succeeded.Add(item);
                 else
                     failed.Add(item);
             }
             //connected.ForEach(item => item.Update(ActiveSail));
         }
         //two lists (failed and succeeded)
         // update succeeded
         // invalidate failed
         DateTime after = DateTime.Now;
         Console.WriteLine("{0} ms", (after - before).TotalMilliseconds);
         StringBuilder b = new StringBuilder("Rebuilt Succeeded:\n");
         if (connected != null)
         {
             foreach (IRebuild item in succeeded)//succeeded
             {
                 UpdateViews(item);
                 b.AppendLine(item.ToString());
             }
             if (failed.Count > 0)
                 b.AppendLine("\nRebuilt Failed:\n");
             foreach (IRebuild item in failed)//failed
             {
                 View.Invalidate(item);
                 Tree.Invalidate(item);
                 b.AppendLine(item.ToString());
             }
             View.Refresh();
         }
     #if DEBUG
         MessageBox.Show(b.ToString());
     #endif
     }
     else if (tag != null)
         UpdateViews(tag);
     return AutoBuild;
 }
예제 #4
0
파일: Sail.cs 프로젝트: GabeTesta/Warps
        /// <summary>
        /// Returns all IRebuild items that are above the tag
        /// </summary>
        /// <param name="tag">the item being used as a watermark, can be null</param>
        /// <returns>a List of IRebuild items</returns>
        public List<IRebuild> Watermark(IRebuild tag)
        {
            List<IRebuild> rets = new List<IRebuild>();

            //watermark mould first (if any)
            if (Mould != null && Mould.Groups != null)
                for (int i = 0; i < Mould.Groups.Count; i++)
                {
                    if (Mould.Groups[i].Watermark(tag, ref rets))
                        break;//break on finding tag
                }

            //watermark layout
            for (int i = 0; i < Layout.Count; i++)
            {
                if (Layout[i].Watermark(tag, ref rets))
                    break;//break on finding tag
            }

            return rets;
        }
예제 #5
0
파일: Sail.cs 프로젝트: GabeTesta/Warps
 public List<MouldCurve> WatermarkCur(IRebuild tag)
 {
     List<MouldCurve> eqs = new List<MouldCurve>();
     foreach (IRebuild rb in Watermark(tag))
     {
         if (rb is MouldCurve)
             eqs.Add(rb as MouldCurve);
     }
     return eqs;
 }
예제 #6
0
파일: TabTree.cs 프로젝트: GabeTesta/Warps
        private void ColorCollection(IRebuild drg, List<IRebuild> items, Color color)
        {
            if (drg == null)
                return;

            items.ForEach(irb =>
            {
                TreeNode found = FindNode(irb);

                if (drg is IGroup)
                {
                    while (found.Parent.Tag != Sail)
                    {
                        found = found.Parent;
                        if (found.Parent == null)
                            break;
                    }
                }
                else if (drg is MouldCurve || drg is Equation)
                {
                    if (!(found.Tag is IGroup))
                    {
                        found.BackColor = color;
                        while (!(found.Tag is IGroup))
                        {
                            found = found.Parent;
                            if (found.Parent == null)
                                break;
                        }
                    }
                }

                //if (found.Tag as IRebuild != drg)
                found.BackColor = color;
            });
        }
예제 #7
0
파일: Sail.cs 프로젝트: GabeTesta/Warps
        public List<IRebuild> GetConnected(IRebuild tag)
        {
            List<IRebuild> connected = null;
            if (tag != null)
            {
                connected = new List<IRebuild>();
                connected.Add(tag);
            }
            foreach (IRebuild item in Layout)
            {
                item.GetConnected(connected);
            }

            return connected;
        }
예제 #8
0
파일: DualView.cs 프로젝트: GabeTesta/Warps
        internal void SelectLayer(IRebuild curve)
        {
            Entity e = ActiveView.Entities.FirstOrDefault(ent => ent.EntityData == curve);

            if (e == null)
                return;

            SelectLayer(e.LayerIndex);
        }
예제 #9
0
파일: DualView.cs 프로젝트: GabeTesta/Warps
 internal void ShowOnly(IRebuild obj)
 {
     HideAll();
     ToggleLayer(obj);
 }
예제 #10
0
파일: DualView.cs 프로젝트: GabeTesta/Warps
        internal void HideLayer(IRebuild p)
        {
            Entity e = ActiveView.Entities.FirstOrDefault(ent => ent.EntityData == p);

            if (e == null)
                return;

            this[0].Layers.TurnOff(e.LayerIndex);// = !this[0].Layers[e.LayerIndex].Visible;
            this[1].Layers.TurnOff(e.LayerIndex);// = !this[1].Layers[e.LayerIndex].Visible;

            Refresh();
        }
예제 #11
0
파일: DualView.cs 프로젝트: GabeTesta/Warps
 internal void Invalidate(IRebuild item)
 {
     for (int i = 0; i < 2; i++)
     {
         for (int j = 0; j < this[i].Entities.Count; j++)
         {
             if (this[i].Entities[j].EntityData == item)
             {
                 this[i].Entities[j].ColorMethod = colorMethodType.byEntity;
                 this[i].Entities[j].Color = InvalidColor;
             }
         }
     }
 }
예제 #12
0
파일: DualView.cs 프로젝트: GabeTesta/Warps
 //private void toolStripMenuItem1_Click(object sender, EventArgs e)
 //{
 //    Warps.Controls.ColorWheelForm cwf = new Controls.ColorWheelForm(ActiveView);
 //    cwf.Location = MousePosition;
 //    cwf.Show(this);
 //}
 internal Layer GetLayer(IRebuild group)
 {
     return ActiveView.Layers.FirstOrDefault(ly => ly.Name == group.Label);
 }
예제 #13
0
파일: DualView.cs 프로젝트: GabeTesta/Warps
        public void Add(IRebuild g)
        {
            Entity[] groupEntities = g.CreateEntities();
            devDept.Eyeshot.Labels.Label[] groupLabels = g.EntityLabel;

            if (groupEntities == null)
                return;

            int layerIndex = AddLayer(g.Label, Color.Black, true);

            for (int i = 0; i < groupEntities.Length; i++)
            {
                if (groupEntities[i].LayerIndex == 0)
                    groupEntities[i].LayerIndex = layerIndex;
                Add(groupEntities[i], groupLabels);
            }
        }
예제 #14
0
        //private void parallelRebuild(List<IRebuild> updated)
        //{
        //    Parallel.ForEach<IRebuild>(updated, item =>
        //    {
        //        item.Update();
        //    });
        //}
        private void UpdateViews(IRebuild item)
        {
            View.Remove(item);

            Tree.BeginUpdate();

            if (item is IGroup)
            {
                View.Add(item as IGroup);
                (item as IGroup).WriteNode();
            }
            else if (item is MouldCurve)
            {
                View.Add(item as MouldCurve);
                (item as MouldCurve).WriteNode();
            }
            else if (item is Equation)
            {
                (item as Equation).WriteNode();
            }
            Tree.Revalidate(item);
            Tree.EndUpdate();
        }
예제 #15
0
파일: TabTree.cs 프로젝트: GabeTesta/Warps
        /// <summary>
        /// this function is going to check whether the target position index is larger 
        /// than the largest parent index in the tree. 
        /// </summary>
        /// <param name="parents">dragged item parents</param>
        /// <param name="trgt">target IRebuild</param>
        /// <param name="aboveMe">the parent that is higher than the target if there is one</param>
        /// <returns>true if index is above dependents, false otherwise</returns>
        private bool CheckWaterMarkIndexParents(List<IRebuild> parents, IRebuild trgt, ref IRebuild aboveMe)
        {
            if (parents.Contains(trgt))
                return false;

            TreeNode target = FindNode(trgt);
            int tarDepth = 0;
            TheIndexOf(trgt, null, ref tarDepth);

            foreach (IRebuild irb in parents)
            {
                TreeNode parent = FindNode(irb);
                int parDepth = 0;
                TheIndexOf(irb, null, ref parDepth);
                if (tarDepth < parDepth)
                {
                    aboveMe = irb;
                    return false;//if the target depth
                }
                // is less than the parent depth, then don't allow
            }

            return true;
        }
예제 #16
0
파일: DualView.cs 프로젝트: GabeTesta/Warps
        internal void ToggleLayer(IRebuild p)
        {
            Entity e;

            if (p is IMouldCurve)
            {
                e = ActiveView.Entities.FirstOrDefault(ent => ent.EntityData == p);

                if (e == null)
                    return;

                this[0].Layers[e.LayerIndex].Visible = !this[0].Layers[e.LayerIndex].Visible;
                this[1].Layers[e.LayerIndex].Visible = !this[1].Layers[e.LayerIndex].Visible;
            }
            else if (p is CurveGroup)
            {
                foreach (IRebuild ir in (p as CurveGroup))
                {
                    e = ActiveView.Entities.FirstOrDefault(ent => ent.EntityData == ir);

                    if (e == null)
                        return;

                    this[0].Layers[e.LayerIndex].Visible = !this[0].Layers[e.LayerIndex].Visible;
                    this[1].Layers[e.LayerIndex].Visible = !this[1].Layers[e.LayerIndex].Visible;
                    break;
                }
            }
            else
            {
                e = ActiveView.Entities.FirstOrDefault(ent => ent.EntityData == p);

                if (e == null)
                    return;

                this[0].Layers[e.LayerIndex].Visible = !this[0].Layers[e.LayerIndex].Visible;
                this[1].Layers[e.LayerIndex].Visible = !this[1].Layers[e.LayerIndex].Visible;
            }

            Refresh();
        }
예제 #17
0
파일: TabTree.cs 프로젝트: GabeTesta/Warps
 private bool CheckWaterMarkIndexParents(List<IRebuild> parents, IRebuild trgt)
 {
     IRebuild throwAway = null;
     return CheckWaterMarkIndexParents(parents, trgt, ref throwAway);
 }
예제 #18
0
파일: TabTree.cs 프로젝트: GabeTesta/Warps
        void TheIndexOf(IRebuild node, List<IGroup> nodes, ref int count)
        {
            if (nodes == null)
                nodes = Sail.Layout;

            foreach (IGroup tn in nodes)
            {
                count++;
                if (tn == node)
                    return;
                if (tn is CurveGroup)
                {
                    if ((tn as CurveGroup).Count > 0 && node is MouldCurve)
                    {
                        foreach (MouldCurve cur in (tn as CurveGroup))
                        {
                            count++;
                            if (cur == node)
                                return;
                        }
                    }
                    else if ((tn as CurveGroup).Count > 0 && node is GuideComb)
                    {
                        foreach (MouldCurve cur in (tn as CurveGroup))
                        {
                            count++;
                            if ((cur as GuideComb) == node)
                                return;
                        }
                    }
                    else
                        count += (tn as CurveGroup).Count;
                }
                else if (tn is VariableGroup)
                {
                    if ((tn as VariableGroup).Count > 0 && node is Equation)
                    {
                        foreach (KeyValuePair<string, Equation> eqs in (tn as VariableGroup))
                        {
                            count++;
                            if (eqs.Key == (node as Equation).Label)
                                return;
                        }
                    }
                    else
                        count += (tn as VariableGroup).Count;
                }
            }
            return;
        }
예제 #19
0
파일: Sail.cs 프로젝트: GabeTesta/Warps
        /// <summary>
        /// Finds the parent group of the specified tag
        /// </summary>
        /// <param name="tag">the item to find the parent of</param>
        /// <returns>the containing IGroup, null if not found</returns>
        public IGroup FindGroup(IRebuild tag)
        {
            if (tag == null)
                return null;
            List<IRebuild> rets = new List<IRebuild>();
            for (int i = Layout.Count - 1; i >= 0; i--)
            {
                if (Layout[i].Watermark(tag, ref rets))
                    return Layout[i];
            }
            if (Mould != null && Mould.Groups != null)
                for (int i = 0; i < Mould.Groups.Count; i++)
                {
                    //check group label
                    if (Mould.Groups[i].Watermark(tag, ref rets))
                        return Mould.Groups[i];//return if match
                }

            return null;
        }
예제 #20
0
파일: TabTree.cs 프로젝트: GabeTesta/Warps
 internal void Invalidate(IRebuild item)
 {
     TreeNode tn = FindNode(item);
     if (tn != null)
     {
         //tn.ForeColor = Color.White;
         tn.BackColor = Color.Firebrick;
         tn.EnsureVisible();
     }
 }
예제 #21
0
파일: Sail.cs 프로젝트: GabeTesta/Warps
        //public List<MouldCurve> GetCurves(object tag)
        //{
        //    bool found = false;
        //    List<MouldCurve> curves = new List<MouldCurve>();
        //    for (int i = 0; i < Layout.Count; i++)
        //    {
        //        if (Layout[i] is CurveGroup)
        //        {
        //            CurveGroup grp = Layout[i] as CurveGroup;
        //            IEnumerable<MouldCurve> mcs = grp.GetCurves(tag);
        //            curves.AddRange(mcs);
        //            if (mcs.Count() != grp.Count)
        //                break;
        //        }
        //        else if (Layout[i] is VariableGroup)
        //        {
        //            VariableGroup grp = Layout[i] as VariableGroup;
        //            found = grp == tag as VariableGroup;
        //            IEnumerable<KeyValuePair<string, Equation>> mcs = grp.GetEquations(tag);
        //            if (mcs.Count() != grp.Count)
        //                break;
        //            if (found)
        //                break;
        //        }
        //        else if (Layout[i] is YarnGroup)
        //        {
        //            YarnGroup grp = Layout[i] as YarnGroup;
        //            found = grp == tag as YarnGroup;
        //            if (found)
        //                break;
        //        }
        //    }
        //    return curves;
        //}
        //public List<KeyValuePair<string, Equation>> GetEquations(object tag)
        //{
        //    bool found = false;
        //    List<KeyValuePair<string, Equation>> equations = new List<KeyValuePair<string, Equation>>();
        //    for (int i = 0; i < Layout.Count; i++)
        //    {
        //        if (Layout[i] is VariableGroup)
        //        {
        //            //continue;
        //            VariableGroup grp = Layout[i] as VariableGroup;
        //            found = grp == tag as VariableGroup;
        //            IEnumerable<KeyValuePair<string, Equation>> mcs = grp.GetEquations(tag);
        //            equations.AddRange(mcs);
        //            if (mcs.Count() != grp.Count)
        //                break;
        //            if (found)
        //                break;
        //        }
        //        else if (Layout[i] is CurveGroup)
        //        {
        //            CurveGroup grp = Layout[i] as CurveGroup;
        //            found = grp == tag as CurveGroup;
        //            IEnumerable<MouldCurve> mcs = grp.GetCurves(tag);
        //            if (mcs.Count() != grp.Count)
        //                break;
        //            if (found)
        //                break;
        //        }
        //        else if (Layout[i] is YarnGroup)
        //        {
        //            YarnGroup grp = Layout[i] as YarnGroup;
        //            found = grp == tag as YarnGroup;
        //            //IEnumerable<KeyValuePair<string, Equation>> mcs = grp.GetEquations(tag);
        //            //if (mcs.Count() != grp.Count)
        //            //	break;
        //            if (found)
        //                break;
        //        }
        //    }
        //    return equations;
        //}
        //public List<MouldCurve> GetAllCurves()
        //{
        //    List<MouldCurve> curves = new List<MouldCurve>();
        //    for (int i = 0; i < Layout.Count; i++)
        //    {
        //        if (Layout[i] is CurveGroup)
        //        {
        //            CurveGroup grp = Layout[i] as CurveGroup;
        //            if (grp == null)
        //                continue;
        //            curves.AddRange(grp.GetAllCurves());
        //        }
        //    }
        //    return curves;
        //}
        //public MouldCurve FindCurve(string name, object tag)
        //{
        //    List<MouldCurve> curves = GetCurves(tag);
        //    return curves.Find(curve => curve.Label == name);
        //}
        public List<IRebuild> Rebuild(IRebuild tag)
        {
            List<IRebuild> updated = null;
            if (tag != null)
            {
                updated = new List<IRebuild>();
                updated.Add(tag);
            }

            foreach (IRebuild item in Layout)
            {
                item.Update(this);// (updated);
            }
            if (tag == null)
                WriteNode();
            return updated;
        }
예제 #22
0
파일: TabTree.cs 프로젝트: GabeTesta/Warps
 //internal void DeSelect(IGroup group)
 //{
 //    TreeNode found = FindNode(group);
 //    if (found != null)
 //        found.BackColor = Color.White;
 //}
 //internal void DeSelect(MouldCurve group)
 //{
 //    TreeNode found = FindNode(group);
 //    if (found != null)
 //        found.BackColor = Color.White;
 //    m_seqtree.Refresh();
 //}
 internal void Remove(IRebuild tag)
 {
     TreeNode found = FindNode(tag);
     if (found != null)
         SeqTree.Nodes.Remove(found);
     SeqTree.Refresh();
 }
예제 #23
0
파일: Sail.cs 프로젝트: GabeTesta/Warps
        /// <summary>
        /// Returns all IRebuild items that are above the tag
        /// </summary>
        /// <param name="tag">the item being used as a watermark, can be null</param>
        /// <param name="Parent">the IGroup the item belongs too (REQUIRED IF YOU ARE ADDING A CURVE)</param>
        /// <returns></returns>
        public List<IRebuild> Watermark(IRebuild tag, IGroup Parent)
        {
            List<IRebuild> rets = new List<IRebuild>();

            //watermark mould first (if any)
            if (Mould != null && Mould.Groups != null)
                for (int i = 0; i < Mould.Groups.Count; i++)
                {
                    if (Mould.Groups[i].Watermark(tag, ref rets))
                        break;//break on finding tag
                }

            int index = -1;

            if (Parent != null)
                index = Layout.IndexOf(Parent); // if the Parent is not null, then don't allow the watermark to go below this group.

            //watermark layout
            for (int i = 0; i < Layout.Count; i++)
            {
                if (index > -1)
                {
                    if (i <= index)
                        if (Layout[i].Watermark(tag, ref rets))
                            break;//break on finding tag

                }
                else if (Layout[i].Watermark(tag, ref rets))
                    break;//break on finding tag

            }

            return rets;
        }
예제 #24
0
파일: TabTree.cs 프로젝트: GabeTesta/Warps
 internal void Revalidate(IRebuild item)
 {
     TreeNode tn = FindNode(item);
     if (tn != null)
     {
         //tn.ForeColor = Color.Black;
         tn.BackColor = Color.White;
     }
 }
예제 #25
0
파일: Sail.cs 프로젝트: GabeTesta/Warps
 public List<Equation> WatermarkEqs(IRebuild tag)
 {
     List<Equation> eqs = new List<Equation>();
     foreach (IRebuild rb in Watermark(tag))
     {
         if (rb is Equation)
             eqs.Add(rb as Equation);
     }
     return eqs;
 }
예제 #26
0
파일: TabTree.cs 프로젝트: GabeTesta/Warps
 private bool CheckWaterMarkIndexChildren(List<IRebuild> children, IRebuild trgt)
 {
     IRebuild throwAway = null;
     return CheckWaterMarkIndexChildren(children, trgt, ref throwAway);
 }
예제 #27
0
 /// <summary>
 /// give it a sail reference and the watermark locations
 /// </summary>
 /// <param name="m_sail">Sail reference</param>
 /// <param name="group">watermark group</param>
 internal void Prep(Sail sail, IRebuild group)
 {
     m_sail = sail;
     AutoFillVariables = m_sail.Watermark(group).ToList<object>();
 }
예제 #28
0
        public int Delete(IRebuild tag)
        {
            if (AutoBuild)
            {
                //List<IRebuild> updated = ActiveSail.Rebuild(tag);
                List<IRebuild> connected = ActiveSail.GetConnected(tag);
                StringBuilder b = new StringBuilder("Invalid:\n");

                foreach (IRebuild item in connected)
                {
                    View.Invalidate(item);
                    Tree.Invalidate(item);
                    b.AppendLine(item.ToString());
                }
            #if DEBUG
                MessageBox.Show(b.ToString());
            #endif
                Tree.Remove(tag);
                ActiveSail.Remove(tag);
                View.Refresh();
                EditMode = false;
                return connected.Count;
            }

            return -1;
        }