Exemple #1
0
		public void AddWidget(GraphicObject g)
		{
			g.Parent = this;
			GraphicObjects.Insert (0, g);

			g.RegisterForLayouting (LayoutingType.Sizing);
		}
Exemple #2
0
        public override bool Contains(GraphicObject goToFind)
        {
            if (Content == null)
                return base.Contains (goToFind);

            if (Content == goToFind)
                return true;
            return Content.Contains (goToFind);
        }
Exemple #3
0
		public void PutOnTop(GraphicObject g)
		{
			if (GraphicObjects.IndexOf(g) > 0)
			{
				GraphicObjects.Remove(g);
				GraphicObjects.Insert(0, g);
				g.AddToRedrawList ();
			}
		}
Exemple #4
0
        public override void AddItem(GraphicObject g)
        {
            base.AddItem (g);

            if (orientation == Orientation.Horizontal)
                g.NotifyValueChanged ("PopDirection", Alignment.Bottom);
            else
                g.NotifyValueChanged ("PopDirection", Alignment.Right);
        }
Exemple #5
0
 public virtual void AddChild(GraphicObject g)
 {
     lock (children)
         Children.Add(g);
     g.Parent = this;
     g.RegisteredLayoutings = LayoutingType.None;
     g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
     g.LayoutChanged += OnChildLayoutChanges;
 }
Exemple #6
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            //only read attributes in GraphicObject IXmlReader implementation
            base.ReadXml(reader);


            using (System.Xml.XmlReader subTree = reader.ReadSubtree())
            {
                subTree.Read(); //skip current node
                subTree.Read(); //read first child

                if (!subTree.IsStartElement())
                {
                    return;
                }

                Type t = Type.GetType("Crow." + subTree.Name);
                if (t == null)
                {
                    Assembly a = Assembly.GetEntryAssembly();
                    foreach (Type expT in a.GetExportedTypes())
                    {
                        if (expT.Name == subTree.Name)
                        {
                            t = expT;
                        }
                    }
                }
                GraphicObject go = (GraphicObject)Activator.CreateInstance(t);

                (go as IXmlSerializable).ReadXml(subTree);

                SetChild(go);

                subTree.Read();//closing tag
            }
        }
Exemple #7
0
 void searchTallestChild()
 {
                 #if DEBUG_LAYOUTING
     Debug.WriteLine("\tSearch tallest child");
                 #endif
     tallestChild       = null;
     contentSize.Height = 0;
     for (int i = 0; i < Children.Count; i++)
     {
         if (!Children [i].Visible)
         {
             continue;
         }
         if (children [i].RegisteredLayoutings.HasFlag(LayoutingType.Height))
         {
             continue;
         }
         if (Children [i].Slot.Height > contentSize.Height)
         {
             contentSize.Height = Children [i].Slot.Height;
             tallestChild       = Children [i];
         }
     }
 }
Exemple #8
0
        public string Clipboard;        //TODO:use object instead for complex copy paste
        public void EnqueueForRepaint(GraphicObject g)
        {
//			if (g.RegisteredLayoutings != LayoutingType.None)
//				return;
            ILayoutable l = g;

            while (l.Parent != null)
            {
                l = l.Parent;
            }
            if (!(l is Interface))
            {
                return;
            }

            lock (DrawingQueue) {
                if (g.IsQueueForRedraw)
                {
                    return;
                }
                DrawingQueue.Enqueue(g);
                g.IsQueueForRedraw = true;
            }
        }
Exemple #9
0
 protected virtual void close()
 {
     Closing.Raise(this, null);
     if (Parent is Interface)
     {
         (Parent as Interface).DeleteWidget(this);
     }
     else
     {
         GraphicObject p = Parent as GraphicObject;
         if (p is Group)
         {
             lock (IFace.UpdateMutex) {
                 RegisterClip(p.ScreenCoordinates(p.LastPaintedSlot));
                 (p as Group).DeleteChild(this);
             }
             //(Parent as Group).RegisterForRedraw ();
         }
         else if (Parent is PrivateContainer)
         {
             (Parent as Container).Child = null;
         }
     }
 }
Exemple #10
0
 void searchLargestChild()
 {
                 #if DEBUG_LAYOUTING
     Debug.WriteLine("\tSearch largest child");
                 #endif
     largestChild      = null;
     contentSize.Width = 0;
     for (int i = 0; i < Children.Count; i++)
     {
         if (!Children [i].Visible)
         {
             continue;
         }
         if (children [i].RegisteredLayoutings.HasFlag(LayoutingType.Width))
         {
             continue;
         }
         if (Children [i].Slot.Width > contentSize.Width)
         {
             contentSize.Width = Children [i].Slot.Width;
             largestChild      = Children [i];
         }
     }
 }
Exemple #11
0
        internal virtual void SetChild(GraphicObject _child)
        {
            if (child != null) {
                contentSize = new Size (0, 0);
                child.LayoutChanged -= OnChildLayoutChanges;
                child.Parent = null;
                this.RegisterForGraphicUpdate ();
            }

            child = _child as GraphicObject;

            if (child != null) {
                child.Parent = this;
                child.LayoutChanged += OnChildLayoutChanges;
                contentSize = child.Slot.Size;
                child.RegisteredLayoutings = LayoutingType.None;
                child.RegisterForLayouting (LayoutingType.Sizing);
            }
        }
Exemple #12
0
 protected override void registerItemClick(GraphicObject g)
 {
     //register ItemClick on the Root node
     TreeView tv = this as TreeView;
     while (!tv.IsRoot) {
         ILayoutable tmp = tv.Parent;
         while (!(tmp is TreeView)) {
             tmp = tmp.Parent;
         }
         tv = tmp as TreeView;
     }
     g.MouseClick += tv.itemClick;
 }
Exemple #13
0
 protected virtual void registerItemClick(GraphicObject g)
 {
     g.MouseClick += itemClick;
 }
Exemple #14
0
 public virtual void RemoveItem(GraphicObject g)
 {
     g.LogicalParent = null;
     items.RemoveChild (g);
     if (items.Children.Count == 0)
         NotifyValueChanged ("HasChildren", false);
 }
Exemple #15
0
		void onImageClick (object sender, Crow.MouseButtonEventArgs e){			
			if (imgSelection == null) {
				imgSelection = CrowInterface.LoadInterface ("#Opuz2015.ui.ImageSelect.goml");
				imgSelection.DataSource = this;
			}
			imgSelection.Visible = true;
			mainMenu.Visible = false;
		}
Exemple #16
0
        protected void loadItem(object o, Group page, string _dataTest)
        {
            if (o == null)            //TODO:surely a threading sync problem
            {
                return;
            }
            GraphicObject g        = null;
            ItemTemplate  iTemp    = null;
            Type          dataType = o.GetType();
            string        itempKey = dataType.FullName;

            if (_dataTest != "TypeOf")
            {
                itempKey = getItempKey(dataType, o, _dataTest);
            }

            if (ItemTemplates.ContainsKey(itempKey))
            {
                iTemp = ItemTemplates [itempKey];
            }
            else
            {
                foreach (string it in ItemTemplates.Keys)
                {
                    Type t = CompilerServices.tryGetType(it);
                    if (t == null)
                    {
                        continue;
                    }
                    if (t.IsAssignableFrom(dataType))                       //TODO:types could be cached
                    {
                        iTemp = ItemTemplates [it];
                        break;
                    }
                }
                if (iTemp == null)
                {
                    iTemp = ItemTemplates ["default"];
                }
            }

            lock (IFace.LayoutMutex) {
                g = iTemp.CreateInstance();
                                #if DESIGN_MODE
                g.design_isTGItem = true;
                                #endif
                page.AddChild(g);
//				if (isPaged)
                g.LogicalParent = this;
                g.MouseDown    += itemClick;
            }

            if (iTemp.Expand != null && g is Expandable)
            {
                Expandable e = g as Expandable;
                e.Expand         += iTemp.Expand;
                e.GetIsExpandable = iTemp.HasSubItems;
            }

            g.DataSource = o;
        }
Exemple #17
0
 public override void SetChild(GraphicObject _child)
 {
     GraphicObject c = child as GraphicObject;
     Group g = child as Group;
     if (c != null) {
         c.LayoutChanged -= OnChildLayoutChanges;
         if (g != null)
             g.ChildrenCleared -= onChildListCleared;
     }
     c = _child as GraphicObject;
     g = _child as Group;
     if (c != null) {
         c.LayoutChanged += OnChildLayoutChanges;
         if (g != null)
             g.ChildrenCleared += onChildListCleared;
     }
     base.SetChild (_child);
 }
Exemple #18
0
 protected override void loadTemplate(GraphicObject template = null)
 {
 }
Exemple #19
0
        public override void onMouseDown(object sender, MouseButtonEventArgs e)
        {
            base.onMouseDown (sender, e);
            go1 = go2 = null;
            init1 = init2 = -1;
            delta = 0;

            GenericStack gs = Parent as GenericStack;
            int ptrSplit = gs.Children.IndexOf (this);
            if (ptrSplit == 0 || ptrSplit == gs.Children.Count - 1)
                return;

            go1 = gs.Children [ptrSplit - 1];
            go2 = gs.Children [ptrSplit + 1];

            if (gs.Orientation == Orientation.Horizontal) {
                initSplit (go1.Width, go1.Slot.Width, go2.Width, go2.Slot.Width);
                min1 = go1.MinimumSize.Width;
                min2 = go2.MinimumSize.Width;
                max1 = go1.MaximumSize.Width;
                max2 = go2.MaximumSize.Width;
                if (init1 >= 0)
                    go1.Width = init1;
                if (init2 >= 0)
                    go2.Width = init2;
            } else {
                initSplit (go1.Height, go1.Slot.Height, go2.Height, go2.Slot.Height);
                min1 = go1.MinimumSize.Height;
                min2 = go2.MinimumSize.Height;
                max1 = go1.MaximumSize.Height;
                max2 = go2.MaximumSize.Height;
                if (init1 >= 0)
                    go1.Height = init1;
                if (init2 >= 0)
                    go2.Height = init2;
            }
        }
Exemple #20
0
 void convertSizeInPix(GraphicObject g1)
 {
 }
Exemple #21
0
		void showFinishedMsg(){
			if (finishedMessage != null)
				return;
			finishedMessage = CrowInterface.LoadInterface("#Opuz2015.ui.Finished.goml");
			finishedMessage.DataSource = this;
		}
Exemple #22
0
 public void DeleteWidget(GraphicObject g)
 {
     g.Visible = false;            //trick to ensure clip is added to refresh zone
     g.ClearBinding();
     GraphicObjects.Remove(g);
 }
Exemple #23
0
 public override bool Contains(GraphicObject goToFind)
 {
     return child == goToFind ? true :
         child == null ? false : child.Contains(goToFind);
 }
Exemple #24
0
        protected void loadItem(int i, Group page)
        {
            if (data [i] == null)            //TODO:surely a threading sync problem
            {
                return;
            }
            GraphicObject g        = null;
            ItemTemplate  iTemp    = null;
            Type          dataType = data [i].GetType();
            string        itempKey = dataType.FullName;

            if (_dataTest != "TypeOf")
            {
                itempKey = getItempKey(dataType, data [i]);
            }

            if (ItemTemplates.ContainsKey(itempKey))
            {
                iTemp = ItemTemplates [itempKey];
            }
            else
            {
                foreach (string it in ItemTemplates.Keys)
                {
                    Type t = Type.GetType(it);
                    if (t == null)
                    {
                        Assembly a = Assembly.GetEntryAssembly();
                        foreach (Type expT in a.GetExportedTypes())
                        {
                            if (expT.Name == it)
                            {
                                t = expT;
                                break;
                            }
                        }
                    }
                    if (t == null)
                    {
                        continue;
                    }
                    if (t.IsAssignableFrom(dataType))                       //TODO:types could be cached
                    {
                        iTemp = ItemTemplates [it];
                        break;
                    }
                }
                if (iTemp == null)
                {
                    iTemp = ItemTemplates ["default"];
                }
            }

            lock (CurrentInterface.LayoutMutex) {
                g = iTemp.CreateInstance(CurrentInterface);
                page.AddChild(g);
                //g.LogicalParent = this;
                registerItemClick(g);
            }

            if (iTemp.Expand != null && g is Expandable)
            {
                (g as Expandable).Expand         += iTemp.Expand;
                (g as Expandable).GetIsExpandable = iTemp.HasSubItems;
            }

            g.DataSource = data [i];
        }
Exemple #25
0
 public virtual void DeleteChild(GraphicObject child)
 {
     RemoveChild(child);
     child.Dispose();
 }
Exemple #26
0
 public override void AddItem(GraphicObject g)
 {
     base.AddItem(g);
     g.NotifyValueChanged("PopDirection", Alignment.Right);
 }
Exemple #27
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            //Template could be either an attribute containing path or expressed inlined
            //as a Template Element
            using (System.Xml.XmlReader subTree = reader.ReadSubtree())
            {
                subTree.Read();

                string template = reader.GetAttribute("Template");
                string tmp      = subTree.ReadOuterXml();

                //Load template from path set as attribute in templated control
                if (string.IsNullOrEmpty(template))
                {
                    //seek for template tag first
                    using (XmlReader xr = new XmlTextReader(tmp, XmlNodeType.Element, null)) {
                        //load template first if inlined

                        xr.Read();                          //read first child
                        xr.Read();                          //skip root node

                        while (!xr.EOF)
                        {
                            if (!xr.IsStartElement())
                            {
                                xr.Read();
                                continue;
                            }
                            if (xr.Name == "ItemTemplate")
                            {
                                string dataType = "default", datas = "", itemTmp;
                                while (xr.MoveToNextAttribute())
                                {
                                    if (xr.Name == "DataType")
                                    {
                                        dataType = xr.Value;
                                    }
                                    else if (xr.Name == "Data")
                                    {
                                        datas = xr.Value;
                                    }
                                }
                                xr.MoveToElement();
                                itemTmp = xr.ReadInnerXml();

                                if (ItemTemplates == null)
                                {
                                    ItemTemplates = new Dictionary <string, ItemTemplate> ();
                                }

                                using (IMLReader iTmp = new IMLReader(null, itemTmp)) {
                                    ItemTemplates [dataType] =
                                        new ItemTemplate(iTmp.RootType, iTmp.GetLoader(), dataType, datas);
                                }
                                if (!string.IsNullOrEmpty(datas))
                                {
                                    ItemTemplates [dataType].CreateExpandDelegate(this);
                                }

                                continue;
                            }
                            if (xr.Name == "Template")
                            {
                                xr.Read();

                                Type t = Type.GetType("Crow." + xr.Name);
                                if (t == null)
                                {
                                    Assembly a = Assembly.GetEntryAssembly();
                                    foreach (Type expT in a.GetExportedTypes())
                                    {
                                        if (expT.Name == xr.Name)
                                        {
                                            t = expT;
                                        }
                                    }
                                }
                                GraphicObject go = (GraphicObject)Activator.CreateInstance(t);
                                (go as IXmlSerializable).ReadXml(xr);

                                loadTemplate(go);
                                continue;
                            }
                            xr.ReadInnerXml();
                        }
                    }
                }
                else
                {
                    loadTemplate(CurrentInterface.Load(template));
                }

                //if no template found, load default one
                if (this.child == null)
                {
                    loadTemplate();
                }

                //normal xml read
                using (XmlReader xr = new XmlTextReader(tmp, XmlNodeType.Element, null)) {
                    xr.Read();
                    base.ReadXml(xr);
                }
            }
        }
Exemple #28
0
        public override void AddChild(GraphicObject child)
        {
            TabItem ti = child as TabItem;
            if (ti == null)
                throw new Exception ("TabView control accept only TabItem as child.");

            ti.MouseDown += Ti_MouseDown;

            if (Children.Count == 0) {
                ti.IsSelected = true;
                SelectedTab = 0;
            }

            base.AddChild (child);
        }
Exemple #29
0
 public override void RemoveChild(GraphicObject child)
 {
     base.RemoveChild (child);
     if (selectedTab > Children.Count - 1)
         SelectedTab--;
     else
         SelectedTab = selectedTab;
 }
Exemple #30
0
 public GraphicObject AddWidget(GraphicObject g, int interfaceIdx = 0)
 {
     if (ifaceControl.Count == 0)//create default orthogonal interface
         addInterfaceControler (new InterfaceControler (
             new Rectangle (0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height)));
     ifaceControl [interfaceIdx].CrowInterface.AddWidget (g);
     return g;
 }
Exemple #31
0
 public override bool Contains(GraphicObject goToFind)
 {
     foreach (GraphicObject w in Items) {
         if (w == goToFind)
             return true;
         if (w.Contains (goToFind))
             return true;
     }
     return base.Contains(goToFind);
 }
 public override bool Contains(GraphicObject goToFind)
 {
     return(child == goToFind ? true :
            child == null ? false : child.Contains(goToFind));
 }
Exemple #33
0
        protected override void loadTemplate(GraphicObject template = null)
        {
            base.loadTemplate (template);

            items = this.child.FindByName ("ItemsContainer") as Group;
            if (items == null)
                throw new Exception ("TemplatedGroup template Must contain a Group named 'ItemsContainer'");
            if (items.Children.Count == 0)
                NotifyValueChanged ("HasChildren", false);
            else
                NotifyValueChanged ("HasChildren", true);
        }
Exemple #34
0
        public override void OnChildLayoutChanges(object sender, LayoutingEventArgs arg)
        {
            GraphicObject go = sender as GraphicObject;

            //Debug.WriteLine ("child layout change: " + go.LastSlots.ToString() + " => " + go.Slot.ToString());
            switch (arg.LayoutType)
            {
            case LayoutingType.Width:
                if (Orientation == Orientation.Horizontal)
                {
                    if (go.Width == Measure.Stretched)
                    {
                        if (stretchedGO == null && Width != Measure.Fit)
                        {
                            stretchedGO = go;
                        }
                        else if (stretchedGO != go)
                        {
                            go.Slot.Width = 0;
                            go.Width      = Measure.Fit;
                            return;
                        }
                    }
                    else
                    {
                        contentSize.Width += go.Slot.Width - go.LastSlots.Width;
                    }

                    if (stretchedGO != null)
                    {
                        int newW = Math.Max(
                            this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1),
                            stretchedGO.MinimumSize.Width);
                        if (stretchedGO.MaximumSize.Width > 0)
                        {
                            newW = Math.Min(newW, stretchedGO.MaximumSize.Width);
                        }
                        if (newW != stretchedGO.Slot.Width)
                        {
                            stretchedGO.Slot.Width = newW;
                            stretchedGO.bmp        = null;
#if DEBUG_LAYOUTING
                            Debug.WriteLine("\tAdjusting Width of " + stretchedGO.ToString());
#endif
                            stretchedGO.LayoutChanged -= OnChildLayoutChanges;
                            stretchedGO.OnLayoutChanges(LayoutingType.Width);
                            stretchedGO.LayoutChanged  += OnChildLayoutChanges;
                            stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
                        }
                    }

                    if (Width == Measure.Fit)
                    {
                        this.RegisterForLayouting(LayoutingType.Width);
                    }

                    this.RegisterForLayouting(LayoutingType.ArrangeChildren);
                    return;
                }
                break;

            case LayoutingType.Height:
                if (Orientation == Orientation.Vertical)
                {
                    if (go.Height == Measure.Stretched)
                    {
                        if (stretchedGO == null && Height != Measure.Fit)
                        {
                            stretchedGO = go;
                        }
                        else if (stretchedGO != go)
                        {
                            go.Slot.Height = 0;
                            go.Height      = Measure.Fit;
                            return;
                        }
                    }
                    else
                    {
                        contentSize.Height += go.Slot.Height - go.LastSlots.Height;
                    }

                    if (stretchedGO != null)
                    {
                        int newH = Math.Max(
                            this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1),
                            stretchedGO.MinimumSize.Height);
                        if (stretchedGO.MaximumSize.Height > 0)
                        {
                            newH = Math.Min(newH, stretchedGO.MaximumSize.Height);
                        }
                        if (newH != stretchedGO.Slot.Height)
                        {
                            stretchedGO.Slot.Height = newH;
                            stretchedGO.bmp         = null;
#if DEBUG_LAYOUTING
                            Debug.WriteLine("\tAdjusting Height of " + stretchedGO.ToString());
#endif
                            stretchedGO.LayoutChanged -= OnChildLayoutChanges;
                            stretchedGO.OnLayoutChanges(LayoutingType.Height);
                            stretchedGO.LayoutChanged   += OnChildLayoutChanges;
                            stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
                        }
                    }

                    if (Height == Measure.Fit)
                    {
                        this.RegisterForLayouting(LayoutingType.Height);
                    }

                    this.RegisterForLayouting(LayoutingType.ArrangeChildren);
                    return;
                }
                break;
            }
            base.OnChildLayoutChanges(sender, arg);
        }
Exemple #35
0
 internal override void itemClick(object sender, MouseButtonEventArgs e)
 {
     GraphicObject tmp = sender as GraphicObject;
     if (!tmp.HasFocus)
         return;
     if (selectedItemContainer != null) {
         selectedItemContainer.Foreground = Color.Transparent;
         selectedItemContainer.Background = Color.Transparent;
     }
     selectedItemContainer = tmp;
     selectedItemContainer.Foreground = SelectionForeground;
     selectedItemContainer.Background = SelectionBackground;
     NotifyValueChanged ("SelectedItem", SelectedItem);
     raiseSelectedItemChanged ();
 }
Exemple #36
0
 public virtual bool Contains(GraphicObject goToFind)
 {
     return false;
 }
Exemple #37
0
        public GraphicObject AddWidget(string path)
        {
            GraphicObject tmp = Load(path);

            return(tmp);
        }
Exemple #38
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            using (System.Xml.XmlReader subTree = reader.ReadSubtree ()) {
                subTree.Read ();
                string tmp = subTree.ReadOuterXml ();

                //seek for template tag
                using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
                    xr.Read ();
                    base.ReadXml (xr);
                }
                //process content
                using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
                    xr.Read (); //skip current node

                    while (!xr.EOF) {
                        xr.Read (); //read first child

                        if (!xr.IsStartElement ())
                            continue;

                        if (xr.Name == "Template"){
                            xr.Skip ();
                            if (!xr.IsStartElement ())
                                continue;
                        }

                        Type t = Type.GetType ("Crow." + xr.Name);
                        if (t == null) {
                            Assembly a = Assembly.GetEntryAssembly ();
                            foreach (Type expT in a.GetExportedTypes ()) {
                                if (expT.Name == xr.Name)
                                    t = expT;
                            }
                        }
                        if (t == null)
                            throw new Exception (xr.Name + " type not found");

                        GraphicObject go = (GraphicObject)Activator.CreateInstance (t);

                        (go as IXmlSerializable).ReadXml (xr);

                        Content = go;

                        xr.Read (); //closing tag
                    }

                }
            }
        }
Exemple #39
0
        public override void OnChildLayoutChanges(object sender, LayoutingEventArgs arg)
        {
            GraphicObject go = sender as GraphicObject;

            //Debug.WriteLine ("child layout change: " + go.LastSlots.ToString() + " => " + go.Slot.ToString());
            switch (arg.LayoutType)
            {
            case LayoutingType.Width:
                if (Orientation == Orientation.Horizontal)
                {
                    if (go.Width == Measure.Stretched)
                    {
                        if (stretchedGO == null && Width != Measure.Fit)
                        {
                            stretchedGO = go;
                        }
                        else if (stretchedGO != go)
                        {
                            go.Slot.Width = 0;
                            go.Width      = Measure.Fit;
                            return;
                        }
                    }
                    else
                    {
                        contentSize.Width += go.Slot.Width - go.LastSlots.Width;
                    }

                    adjustStretchedGo(LayoutingType.Width);

                    if (Width == Measure.Fit)
                    {
                        this.RegisterForLayouting(LayoutingType.Width);
                    }

                    this.RegisterForLayouting(LayoutingType.ArrangeChildren);
                    return;
                }
                break;

            case LayoutingType.Height:
                if (Orientation == Orientation.Vertical)
                {
                    if (go.Height == Measure.Stretched)
                    {
                        if (stretchedGO == null && Height != Measure.Fit)
                        {
                            stretchedGO = go;
                        }
                        else if (stretchedGO != go)
                        {
                            go.Slot.Height = 0;
                            go.Height      = Measure.Fit;
                            return;
                        }
                    }
                    else
                    {
                        contentSize.Height += go.Slot.Height - go.LastSlots.Height;
                    }

                    adjustStretchedGo(LayoutingType.Height);

                    if (Height == Measure.Fit)
                    {
                        this.RegisterForLayouting(LayoutingType.Height);
                    }

                    this.RegisterForLayouting(LayoutingType.ArrangeChildren);
                    return;
                }
                break;
            }
            base.OnChildLayoutChanges(sender, arg);
        }
Exemple #40
0
 public GraphicObject AddWidget(GraphicObject g, int interfaceIdx = 0)
 {
     checkDefaultIFace();
     ifaceControl [interfaceIdx].CrowInterface.AddWidget(g);
     return(g);
 }
Exemple #41
0
 public override void AddItem(GraphicObject g)
 {
     base.AddItem (g);
     g.NotifyValueChanged ("PopDirection", Alignment.Right);
 }
Exemple #42
0
 public static string GetIcon(this GraphicObject go)
 {
     return("#Crow.Coding.icons.toolbox." + go.GetType().FullName + ".svg");
 }
Exemple #43
0
 protected virtual void registerItemClick(GraphicObject g)
 {
     g.MouseClick += itemClick;
 }
Exemple #44
0
 public override void AddChild(GraphicObject child)
 {
     base.AddChild (child);
     this.RegisterForLayouting (LayoutingType.ArrangeChildren);
 }
Exemple #45
0
 public void DeleteWidget(GraphicObject g, int interfaceIdx = 0)
 {
     ifaceControl [interfaceIdx].CrowInterface.DeleteWidget(g);
 }
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            using (System.Xml.XmlReader subTree = reader.ReadSubtree()) {
                subTree.Read();
                string tmp = subTree.ReadOuterXml();

                //seek for template tag
                using (XmlReader xr = new XmlTextReader(tmp, XmlNodeType.Element, null)) {
                    xr.Read();
                    base.ReadXml(xr);
                }
                //process content
                using (XmlReader xr = new XmlTextReader(tmp, XmlNodeType.Element, null)) {
                    xr.Read();                      //skip current node

                    while (!xr.EOF)
                    {
                        xr.Read();                          //read first child

                        if (!xr.IsStartElement())
                        {
                            continue;
                        }

                        if (xr.Name == "Template")
                        {
                            xr.Skip();
                            if (!xr.IsStartElement())
                            {
                                continue;
                            }
                        }

                        Type t = Type.GetType("Crow." + xr.Name);
                        if (t == null)
                        {
                            Assembly a = Assembly.GetEntryAssembly();
                            foreach (Type expT in a.GetExportedTypes())
                            {
                                if (expT.Name == xr.Name)
                                {
                                    t = expT;
                                }
                            }
                        }
                        if (t == null)
                        {
                            throw new Exception(xr.Name + " type not found");
                        }

                        GraphicObject go = (GraphicObject)Activator.CreateInstance(t);

                        (go as IXmlSerializable).ReadXml(xr);

                        Content = go;

                        xr.Read();                          //closing tag
                    }
                }
            }
        }
Exemple #47
0
 /// <summary>
 /// override this to handle specific steps in child addition in derived class,
 /// and don't forget to call the base.SetChild
 /// </summary>
 public virtual void SetChild(GraphicObject _child)
 {
     base.SetChild(_child);
 }
Exemple #48
0
 public override void RemoveChild(GraphicObject child)
 {
     base.RemoveChild(child);
     this.RegisterForLayouting(LayoutingType.ArrangeChildren);
 }
Exemple #49
0
 public virtual void AddItem(GraphicObject g)
 {
     items.AddChild(g);
     g.LogicalParent = this;
     NotifyValueChanged("HasChildren", true);
 }
Exemple #50
0
 void convertSizeInPix(GraphicObject g1)
 {
 }
Exemple #51
0
 //TODO: x,y position should be taken in account for computation of width and height
 void resetChildrenMaxSize()
 {
     largestChild = null;
     tallestChild = null;
     contentSize  = 0;
 }
Exemple #52
0
		void initInterface(){
			//special event handlers fired only if mouse not in interface objects
			//for scene mouse handling
			MouseMove += Mouse_Move;
			MouseButtonDown += Mouse_ButtonDown;
			MouseButtonUp += Mouse_ButtonUp;
			MouseWheelChanged += Mouse_WheelChanged;
			//KeyboardKeyDown += MainWin_KeyboardKeyDown;

			CrowInterface.LoadInterface("#Opuz2015.ui.fps.crow").DataSource = this;
			mainMenu = CrowInterface.LoadInterface("#Opuz2015.ui.MainMenu.goml");
			mainMenu.DataSource = this;
			mainMenu.Visible = false;

			Crow.CompilerServices.ResolveBindings (this.Bindings);
			mainMenu.Visible = true;
		}
Exemple #53
0
        /// <summary>
        /// Compile events expression in GOML attributes
        /// </summary>
        /// <param name="binding">Event binding details</param>
        public static void CompileEventSource(Binding binding)
        {
#if DEBUG_BINDING
            Debug.WriteLine("\tCompile Event Source => " + binding.ToString());
#endif

            Type target_type = binding.Source.Instance.GetType();

            #region Retrieve EventHandler parameter type
            MethodInfo       evtInvoke       = binding.Source.Event.EventHandlerType.GetMethod("Invoke");
            ParameterInfo [] evtParams       = evtInvoke.GetParameters();
            Type             handlerArgsType = evtParams [1].ParameterType;
            #endregion

            Type []       args = { typeof(object), typeof(object), handlerArgsType };
            DynamicMethod dm   = new DynamicMethod(binding.CreateNewDynMethodId(),
                                                   typeof(void),
                                                   args,
                                                   target_type);


            #region IL generation
            ILGenerator il = dm.GetILGenerator(256);

            string src = binding.Expression.Trim();

            if (!(src.StartsWith("{") || src.EndsWith("}")))
            {
                throw new Exception(string.Format("GOML:Malformed {0} Event handler: {1}", binding.Source.Member.Name, binding.Expression));
            }

            src = src.Substring(1, src.Length - 2);
            string [] srcLines = src.Split(new char [] { ';' });

            foreach (string srcLine in srcLines)
            {
                string statement = srcLine.Trim();

                string [] operandes = statement.Split(new char [] { '=' });
                if (operandes.Length < 2)                 //not an affectation
                {
                    continue;
                }
                string lop = operandes [0].Trim();
                string rop = operandes [operandes.Length - 1].Trim();

                #region LEFT OPERANDES
                GraphicObject lopObj = binding.Source.Instance as GraphicObject;                    //default left operand base object is
                //the first arg (object sender) of the event handler

                il.Emit(OpCodes.Ldarg_0);                   //load sender ref onto the stack

                string [] lopParts = lop.Split(new char [] { '.' });
                if (lopParts.Length > 1)                  //should search also for member of es.Source
                {
                    MethodInfo FindByNameMi = typeof(GraphicObject).GetMethod("FindByName");
                    for (int j = 0; j < lopParts.Length - 1; j++)
                    {
                        il.Emit(OpCodes.Ldstr, lopParts [j]);
                        il.Emit(OpCodes.Callvirt, FindByNameMi);
                    }
                }

                int i = lopParts.Length - 1;

                MemberInfo [] lopMbis = lopObj.GetType().GetMember(lopParts [i]);

                if (lopMbis.Length < 1)
                {
                    throw new Exception(string.Format("CROW BINDING: Member not found '{0}'", lop));
                }

                OpCode  lopSetOC;
                dynamic lopSetMbi;
                Type    lopT = null;
                switch (lopMbis [0].MemberType)
                {
                case MemberTypes.Property:
                    PropertyInfo lopPi = target_type.GetProperty(lopParts [i]);
                    MethodInfo   dstMi = lopPi.GetSetMethod();
                    lopT      = lopPi.PropertyType;
                    lopSetMbi = dstMi;
                    lopSetOC  = OpCodes.Callvirt;
                    break;

                case MemberTypes.Field:
                    FieldInfo dstFi = target_type.GetField(lopParts [i]);
                    lopT      = dstFi.FieldType;
                    lopSetMbi = dstFi;
                    lopSetOC  = OpCodes.Stfld;
                    break;

                default:
                    throw new Exception(string.Format("GOML:member type not handle: {0}", lopParts [i]));
                }
                #endregion

                #region RIGHT OPERANDES
                if (rop.StartsWith("\'"))
                {
                    if (!rop.EndsWith("\'"))
                    {
                        throw new Exception(string.Format
                                                ("GOML:malformed string constant in handler: {0}", rop));
                    }
                    string strcst = rop.Substring(1, rop.Length - 2);

                    il.Emit(OpCodes.Ldstr, strcst);
                }
                else
                {
                    if (lopT.IsEnum)
                    {
                        throw new NotImplementedException();
                    }

                    MethodInfo lopParseMi = lopT.GetMethod("Parse");
                    if (lopParseMi == null)
                    {
                        throw new Exception(string.Format
                                                ("GOML:no parse method found in: {0}", lopT.Name));
                    }
                    il.Emit(OpCodes.Ldstr, rop);
                    il.Emit(OpCodes.Callvirt, lopParseMi);
                    il.Emit(OpCodes.Unbox_Any, lopT);
                }

                #endregion

                //emit left operand assignment
                il.Emit(lopSetOC, lopSetMbi);
            }

            il.Emit(OpCodes.Ret);

            #endregion

            Delegate   del        = dm.CreateDelegate(binding.Source.Event.EventHandlerType, binding.Source.Instance);
            MethodInfo addHandler = binding.Source.Event.GetAddMethod();
            addHandler.Invoke(binding.Source.Instance, new object [] { del });

            binding.Resolved = true;
        }
Exemple #54
0
		void closeCurrentPuzzle(){
			currentState = GameState.Init;

			if (finishedMessage != null) {
				CrowInterface.DeleteWidget (finishedMessage);
				finishedMessage = null;
			}
			mainMenu.Visible = true;
			if (puzzle != null)
				puzzle.Dispose();
			puzzle = null;
		}
Exemple #55
0
        //TODO: move loadTemplate and ResolveBinding in TemplatedContainer
        protected override void loadTemplate(GraphicObject template = null)
        {
            base.loadTemplate(template);

            _contentContainer = this.child.FindByName("Content") as Container;
        }
Exemple #56
0
		public virtual void onMouseDoubleClick(object sender, MouseButtonEventArgs e){
			GraphicObject p = Parent as GraphicObject;
			if (p != null)
				p.onMouseDoubleClick(sender,e);
			MouseDoubleClick.Raise (this, e);
		}
Exemple #57
0
 protected override void loadTemplate(GraphicObject template)
 {
 }
Exemple #58
0
		public virtual bool Contains(GraphicObject goToFind){
			return false;
		}
Exemple #59
0
        protected override void loadTemplate(GraphicObject template = null)
        {
            base.loadTemplate (template);

            _contentContainer = this.child.FindByName ("Content") as Container;
            _tabTitle = this.child.FindByName ("TabTitle");
        }
Exemple #60
0
 public virtual void AddItem(GraphicObject g)
 {
     items.AddChild (g);
     g.LogicalParent = this;
     NotifyValueChanged ("HasChildren", true);
 }