public void SelectGalleryIcon(GalleryIcon selectedIcon)
 {
     foreach (GalleryIcon icon in _icons)
     {
         if (icon == selectedIcon)
         {
             icon.Selected2 = true;
         }
         else
         {
             icon.Selected2 = false;
         }
     }
 }
Beispiel #2
0
        public override void OnClick(object sender, TappedRoutedEventArgs e)
        {
            if (sender is DrawingCanvas)
            {
                DrawingCanvas canvas = sender as DrawingCanvas;

                if (clicked)
                {
                    clicked = false;

                    Point pos = new Point()
                    {
                        X = rect.Margin.Left,
                        Y = rect.Margin.Top
                    };
                    DrawableClassObject clObject = ModelManager.GetInstance()
                                                   .CreateNewClass(new Point(rect.Width, rect.Height), rect.Fill, VisualShape.Rectangle, pos, 1);
                    EditPage.Instance.ClassGallery.FillClasses();
                    EditPage.Instance.DrawClassView(clObject);
                    EditPage.Instance.PropertiesPanel.FillWithClass(clObject);
                    return;
                }

                rect = new Rectangle();
                double x = e.GetPosition(canvas).X;
                double y = e.GetPosition(canvas).Y;
                rect.Fill   = _randomColor.Shuffle();
                thickness   = new Thickness(x, y, 0, 0);
                rect.Margin = thickness;
                off_x       = x;
                off_y       = y;
                canvas.AddUIControl(rect);

                clicked = true;
            }
            else if (sender is GalleryIcon)
            {
                GalleryIcon icon = sender as GalleryIcon;
                EditPage.Instance.DrawClassView(icon.ClassObject);
            }
        }
Beispiel #3
0
 public override void OnClick(object sender, TappedRoutedEventArgs e)
 {
     if (!(sender is GalleryIcon) && !(sender is Shape))
     {
         return;
     }
     if (sender is GalleryIcon)
     {
         GalleryIcon icon = sender as GalleryIcon;
         EditPage.Instance.DrawClassView(icon.ClassObject);
     }
     else if (sender is Shape)
     {
         Shape          shape   = sender as Shape;
         Flyout         fly     = new Flyout();
         InstanceFlyout content = new InstanceFlyout((shape.Tag as SceneNode).Instance, fly);
         fly.Content = content;
         fly.ShowAt(shape);
         EditPage.Instance.PropertiesPanel.FillWithClass((shape.Tag as SceneNode).Instance.ClassObject);
     }
 }
        public void FillClasses()
        {
            List <DrawableClassObject> classes = Model.ModelManager.GetInstance().GetClasses();

            _icons = new List <GalleryIcon>();
            PreviewGridView.Items.Clear();
            foreach (DrawableClassObject cl in classes)
            {
                InstanceObject        instance  = cl.Instances.First();
                List <InstanceObject> instances = new List <InstanceObject>();
                instances.Add(instance);
                Canvas canvas = new Canvas();
                new Angelina().ExploreAfrica(new SceneGraph(instances), canvas);
                canvas.RenderTransform = new ScaleTransform()
                {
                    ScaleX = 0.1, ScaleY = 0.1
                };
                canvas.HorizontalAlignment = HorizontalAlignment.Center;
                GalleryIcon icon = new GalleryIcon(this, canvas, cl);
                _icons.Add(icon);
                PreviewGridView.Items.Add(icon);
            }
        }
        public override void OnClick(object sender, TappedRoutedEventArgs e)
        {
            if (sender is GalleryIcon)
            {
                GalleryIcon icon = sender as GalleryIcon;

                if (!_clicked)
                {
                    _clicked = true;
                    // select instance to add

                    EditPage.Instance.CurrentCanvas.Opacity          = 1;
                    EditPage.Instance.CurrentCanvas.IsHitTestVisible = true;

                    InstanceObject instance = icon.ClassObject.Instances.First();

                    _node = new SceneNode(instance, 1);

                    _clObject = icon.ClassObject;
                }
            }
            else if (sender is DrawingCanvas)
            {
                DrawingCanvas canvas = sender as DrawingCanvas;

                if (_clicked)
                {
                    // create new instance


                    Point pos = new Point()
                    {
                        X = e.GetPosition(canvas).X - _clObject.Size.X / 2,
                        Y = e.GetPosition(canvas).Y - _clObject.Size.Y / 2
                    };

                    Model.ModelManager.GetInstance().CreateInstanceOfClass(_clObject, pos, 1);
                    EditPage.Instance.Redraw();
                    _clicked = false;
                    _node    = null;
                    return;
                }
            }
            else if (sender is Shape && _clicked)
            {
                //    _node.Instance.Scale = 1;
                Point pos = new Point()
                {
                    X = e.GetPosition(sender as Shape).X - _clObject.Size.X / 2,
                    Y = e.GetPosition(sender as Shape).Y - _clObject.Size.Y / 2
                };
                InstanceObject inst = new InstanceObject(_node.Instance.ClassObject, pos, 1);
                ((sender as Shape).Tag as SceneNode).Instance.ClassObject.AddAttribute(inst);
                EditPage.Instance.Redraw();
                _clicked = false;
                _node    = null;
                return;
            }

            //  Debug.WriteLine(_clicked + "");
        }