示例#1
0
        public static ICanvasSelectableObject CanvasFromDrawableObject(IBlackboardObject drawable)
        {
            ICanvasDrawableObject d = CanvasFromDrawableObjectRegistry.CanvasFromDrawableObject(drawable);

            d.IDrawableObject = drawable;
            return(d);
        }
示例#2
0
        public IBlackboardObject GetClosestObject(Coordinate coordinate)
        {
            double            DistanceClosestM = double.MaxValue;
            IBlackboardObject closestObj       = null;

            foreach (var obj in BlackboardController.Objects)
            {
                if (obj is T)
                {
                    double ThisDistanceM = obj.DistanceToM(coordinate);
                    if (closestObj == null)
                    {
                        DistanceClosestM = ThisDistanceM;
                        closestObj       = obj;
                    }
                    else
                    {
                        if (obj.DistanceToM(closestObj.Coordinate) < DistanceClosestM)
                        {
                            DistanceClosestM = ThisDistanceM;
                            closestObj       = obj;
                        }
                    }
                }
            }
            return(closestObj);
        }
示例#3
0
        ICanvasSelectableObject Add(IBlackboardObject drawable)
        {
            ICanvasSelectableObject cso = Utils.CanvasFromDrawableObject(drawable);

            AddObject(cso);
            return(cso);
        }
示例#4
0
        public static ICanvasDrawableObject CanvasFromDrawableObject(IBlackboardObject srcInstance)
        {
            TypeAndAssembly ta     = CanvasFromDrawableObjectMap [srcInstance.GetType().ToString()];
            ObjectHandle    handle = null;

            handle = Activator.CreateInstance(ta.AssemblyName, ta.Type.ToString());
            return((ICanvasDrawableObject)handle.Unwrap());
        }
示例#5
0
文件: Utils.cs 项目: GNOME/longomatch
 public static ICanvasSelectableObject CanvasFromDrawableObject(IBlackboardObject drawable)
 {
     string objecttype = String.Format ("LongoMatch.Drawing.CanvasObjects.Blackboard.{0}Object",
                             drawable.GetType ().ToString ().Split ('.').Last ());
     ObjectHandle handle = Activator.CreateInstance (null, objecttype);
     ICanvasDrawableObject d = (ICanvasDrawableObject)handle.Unwrap ();
     d.IDrawableObject = drawable;
     return d;
 }
示例#6
0
        public static ICanvasSelectableObject CanvasFromDrawableObject(IBlackboardObject drawable)
        {
            string objecttype = String.Format("LongoMatch.Drawing.CanvasObjects.Blackboard.{0}Object",
                                              drawable.GetType().ToString().Split('.').Last());
            ObjectHandle          handle = Activator.CreateInstance(null, objecttype);
            ICanvasDrawableObject d      = (ICanvasDrawableObject)handle.Unwrap();

            d.IDrawableObject = drawable;
            return(d);
        }
示例#7
0
        void HandleDrawableChangedEvent(IBlackboardObject drawable)
        {
            selectedDrawable = drawable as Drawable;

            colorbutton.Sensitive = !(drawable is Text);

            ignoreChanges = true;
            if (selectedDrawable == null)
            {
                colorbutton.Color           = Misc.ToGdkColor(blackboard.Color);
                textcolorbutton.Color       = Misc.ToGdkColor(blackboard.TextColor);
                backgroundcolorbutton.Color = Misc.ToGdkColor(blackboard.TextBackgroundColor);
                backgroundcolorbutton.Alpha = Color.ByteToUShort(blackboard.TextBackgroundColor.A);
                linesizespinbutton.Value    = OriginalSize(blackboard.LineWidth);
                if (blackboard.LineStyle == LineStyle.Normal)
                {
                    stylecombobox.Active = 0;
                }
                else
                {
                    stylecombobox.Active = 1;
                }
                typecombobox.Active = (int)blackboard.LineType;
            }
            else
            {
                if (drawable is Text)
                {
                    textcolorbutton.Color       = Misc.ToGdkColor((selectedDrawable as Text).TextColor);
                    backgroundcolorbutton.Color = Misc.ToGdkColor(selectedDrawable.FillColor);
                    backgroundcolorbutton.Alpha = Color.ByteToUShort(selectedDrawable.FillColor.A);
                    textspinbutton.Value        = OriginalSize((selectedDrawable as Text).TextSize);
                }
                else
                {
                    colorbutton.Color = Misc.ToGdkColor(selectedDrawable.StrokeColor);
                }
                if (drawable is Line)
                {
                    typecombobox.Active = (int)(drawable as Line).Type;
                }
                linesizespinbutton.Value = OriginalSize(selectedDrawable.LineWidth);
                if (selectedDrawable.Style == LineStyle.Normal)
                {
                    stylecombobox.Active = 0;
                }
                else
                {
                    stylecombobox.Active = 1;
                }
            }
            ignoreChanges = false;
        }
示例#8
0
 void HandleConfigureObjectEvent(IBlackboardObject drawable, DrawTool tool)
 {
     if (drawable is Text)
     {
         if (tool == DrawTool.Text)
         {
             EditText(drawable as Text);
         }
         else if (tool == DrawTool.Player)
         {
             EditPlayer(drawable as Text);
         }
     }
 }
示例#9
0
        void HandleShowMenuEvent(IBlackboardObject drawable)
        {
            Menu     m    = new Menu();
            MenuItem item = new MenuItem(Catalog.GetString("Delete"));

            item.Activated += (sender, e) => blackboard.DeleteSelection();
            m.Add(item);
            if (drawable is Text)
            {
                MenuItem edit = new MenuItem(Catalog.GetString("Edit"));
                edit.Activated += (sender, e) => EditText(drawable as Text);
                m.Add(edit);
            }
            m.ShowAll();
            m.Popup();
        }
示例#10
0
 void HandleShowMenuEvent(IBlackboardObject drawable)
 {
     Menu m = new Menu ();
     MenuItem item = new MenuItem (Catalog.GetString ("Delete"));
     item.Activated += (sender, e) => blackboard.DeleteSelection ();
     m.Add (item);
     if (drawable is Text) {
         MenuItem edit = new MenuItem (Catalog.GetString ("Edit"));
         edit.Activated += (sender, e) => EditText (drawable as Text);
         m.Add (edit);
     }
     m.ShowAll ();
     m.Popup ();
 }
示例#11
0
        void HandleDrawableChangedEvent(IBlackboardObject drawable)
        {
            selectedDrawable = drawable as Drawable;

            colorbutton.Sensitive = !(drawable is Text);

            ignoreChanges = true;
            if (selectedDrawable == null) {
                colorbutton.Color = Misc.ToGdkColor (blackboard.Color);
                textcolorbutton.Color = Misc.ToGdkColor (blackboard.TextColor);
                backgroundcolorbutton.Color = Misc.ToGdkColor (blackboard.TextBackgroundColor);
                backgroundcolorbutton.Alpha = Color.ByteToUShort (blackboard.TextBackgroundColor.A);
                linesizespinbutton.Value = OriginalSize (blackboard.LineWidth);
                if (blackboard.LineStyle == LineStyle.Normal) {
                    stylecombobox.Active = 0;
                } else {
                    stylecombobox.Active = 1;
                }
                typecombobox.Active = (int)blackboard.LineType;
            } else {
                if (drawable is Text) {
                    textcolorbutton.Color = Misc.ToGdkColor ((selectedDrawable as Text).TextColor);
                    backgroundcolorbutton.Color = Misc.ToGdkColor (selectedDrawable.FillColor);
                    backgroundcolorbutton.Alpha = Color.ByteToUShort (selectedDrawable.FillColor.A);
                    textspinbutton.Value = OriginalSize ((selectedDrawable as Text).TextSize);
                } else {
                    colorbutton.Color = Misc.ToGdkColor (selectedDrawable.StrokeColor);
                }
                if (drawable is Line) {
                    typecombobox.Active = (int)(drawable as Line).Type;
                }
                linesizespinbutton.Value = OriginalSize (selectedDrawable.LineWidth);
                if (selectedDrawable.Style == LineStyle.Normal) {
                    stylecombobox.Active = 0;
                } else {
                    stylecombobox.Active = 1;
                }
            }
            ignoreChanges = false;
        }
示例#12
0
 void HandleConfigureObjectEvent(IBlackboardObject drawable, DrawTool tool)
 {
     if (drawable is Text) {
         if (tool == DrawTool.Text) {
             EditText (drawable as Text);
         } else if (tool == DrawTool.Player) {
             EditPlayer (drawable as Text);
         }
     }
 }
示例#13
0
 ICanvasSelectableObject Add(IBlackboardObject drawable)
 {
     ICanvasSelectableObject cso = Utils.CanvasFromDrawableObject (drawable);
     AddObject (cso);
     return cso;
 }