Esempio n. 1
0
        //Bearbeiten eines einzelnen IDrawable
        public static void EditDraw(IDrawable obj, EditType edit)
        {
            try
            {
                //EditType wird als string abgespeichert
                var editString = edit.ToString();

                if (obj.GetType().BaseType == typeof(DrawObject))
                {
                    //drwaObject ist obj als DrawObject, so kann auf die DrawObject Funktionen zugegriffen werden
                    var drawObject = (DrawObject)obj;

                    //objekt wird bearbeitet
                    drawObject.Edit((DrawObject.EditObject)Enum.Parse(typeof(DrawObject.EditObject), editString));
                }
                else if (obj.GetType().BaseType == typeof(DrawGroup))
                {
                    var drawGroup = (DrawGroup)obj;

                    //objekt wird bearbeitet
                    drawGroup.Edit((DrawGroup.EditGroup)Enum.Parse(typeof(DrawGroup.EditGroup), editString));
                }

                // Maße werden aktualisiert
                MainWindow.ThisWindow.Measure();
            }
            catch { }
        }
Esempio n. 2
0
        /// <summary>
        /// Informationen zum Senden für eine Linie
        /// </summary>
        private static string GetObjectInformation(this IDrawable drawable)
        {
            if (drawable.GetType() == typeof(DrawLine))
            {
                //Distanz Start-Ende in X Richtung
                var xDistance = Math.Round(MainWindow.PixelToCentimeter(drawable.Width), 5);

                //Distanz Start-Ende in Y Richtung
                var yDistance = Math.Round(MainWindow.PixelToCentimeter(drawable.Height), 5);

                // string der gesendet werden soll
                var returnString = $"#OBJL{xDistance}/{yDistance}";

                // Kommas werden durch Punkte ersetzt
                returnString = returnString.Replace(",", ".");

                // Information wird zurückgegeben
                return(returnString);
            }
            else if (drawable.GetType() == typeof(DrawCircle))
            {
                var circle = (DrawCircle)drawable;

                // Radius in cm
                var radius = Math.Round(MainWindow.PixelToCentimeter(circle.Radius), 5);

                // Größe
                var circleSizeAngle = Math.Round(circle.CircleSizeAngle, 5);

                // erster Winkel
                var firstAngle = Math.Round(circle.StartAngle - 90, 5);

                if (circle.IsInverted)
                {
                    firstAngle = Math.Round(circle.StartAngle + 90, 5);
                }

                // Invertierung wird als 1 oder 0 übertragen
                int isInverted = circle.IsInverted ? 1:0;

                // string der gesendet werden soll
                var returnString = $"#OBJC{radius}/{circleSizeAngle}/{firstAngle}/{isInverted}";

                // Kommas werden durch Punkte ersetzt
                returnString = returnString.Replace(",", ".");

                // Informationen werden zurückgegeben
                return(returnString);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        public bool TrySelectShape(IDrawable shape)
        {
            if (shape == null)
            {
                if (this.selectedShape != null)
                {
                    this.selectedShape.IsSelected = false;
                }

                this.selectedShape = null;
                return(true);
            }
            else if (shape.GetType() == this.ShapeType)
            {
                if (this.selectedShape != null)
                {
                    this.selectedShape.IsSelected = false;
                }

                this.selectedShape            = shape as Shape;
                this.selectedShape.IsSelected = true;
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
 public void DrawShape(IDrawable shape)
 {
     Console.WriteLine($"I'm {shape.GetType().Name}");
     //if (shape is Circle)
     //{
     //    Console.WriteLine("I'm Circle");
     //}
     //else if (shape is Rectangle)
     //{
     //    Console.WriteLine("I'm Recangle");
     //}
     //else if (shape is Square)
     //{
     //    Console.WriteLine("I'm Square");
     //}
 }
 private int priority(IDrawable idrawable)
 {
     if (idrawable.GetType() == typeof(Player)
         || idrawable.GetType() == typeof(DummyBoss)
         || idrawable.GetType() == typeof(Boss)) {
         return 0;
     } else if (idrawable.GetType() == typeof(HUD)) {
         return 1;
     } else if (idrawable.GetType() == typeof(Fader)) {
         return 2;
     } else if (idrawable.GetType() == typeof(PauseScreen)) {
         return 4;
     } else {
         return 3;
     }
 }
        private void updateProperties(IDrawable source)
        {
            Clear();

            if (source == null)
            {
                return;
            }

            var allMembers = new HashSet <MemberInfo>(new MemberInfoComparer());

            foreach (var type in source.GetType().EnumerateBaseTypes())
            {
                type.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)
                .Where(m => m is FieldInfo || (m is PropertyInfo pi && pi.GetMethod != null && !pi.GetIndexParameters().Any()))
                .ForEach(m => allMembers.Add(m));
            }

            // Order by upper then lower-case, and exclude auto-generated backing fields of properties
            AddRange(allMembers.OrderBy(m => m.Name[0]).ThenBy(m => m.Name)
                     .Where(m => m.GetCustomAttribute <CompilerGeneratedAttribute>() == null)
                     .Where(m => m.GetCustomAttribute <DebuggerBrowsableAttribute>()?.State != DebuggerBrowsableState.Never)
                     .Select(m => new PropertyItem(m, source)));
        }
Esempio n. 7
0
        public void CustomRefresh()
        {
            this.Refresh();

            if (SelectedItem != null)
            {
                OpacityChangeBtn.Enabled = true;
                OpacityChangeBtn.Value   = SelectedItem.GetOpacity();
                deleteBtn.Enabled        = true;
                if (SelectedItem.GetType().Name != "GroupOfItems")
                {
                    copyBtn.Enabled = true;
                }
                nameTextBox.Enabled = true;
                nameTextBox.Text    = SelectedItem.Name;
            }
            else
            {
                OpacityChangeBtn.Enabled = false;
                OpacityChangeBtn.Value   = 0;
                deleteBtn.Enabled        = false;
                copyBtn.Enabled          = false;
                nameTextBox.Enabled      = false;
                nameTextBox.Text         = String.Empty;
            }

            if (this.Items.Count > 0)
            {
                findItemBtn.Enabled = true;
            }
            else
            {
                findItemBtn.Enabled = false;
            }

            if (this.copied != null)
            {
                pasteBtn.Enabled = true;
            }
            else
            {
                pasteBtn.Enabled = false;
            }

            if (this.groupOfItems != null && SelectedItem != null && this.SelectedItem.GetType().Name == "GroupOfItems")
            {
                breakBtn.Enabled = true;
                groupBtn.Enabled = false;
                copyBtn.Enabled  = false;
            }
            else
            {
                if (this.Items.Count > 1 && this.groupOfItems == null)
                {
                    groupBtn.Enabled = true;
                }
                else
                {
                    groupBtn.Enabled = false;
                }
                breakBtn.Enabled = false;
            }
        }
Esempio n. 8
0
        // Handle layers
        public bool Add(IDrawable renderable)
        {
            // Abort if parameter is null
            if (renderable == null)
            {
                GameConsole.WriteLine(string.Format("{0}: Tried to add a non-existing Renderable (renderable = null)", GetType().Name), GameConsole.MessageType.Error); // Debug
                return(false);
            }

            // Abort if entity is not found
            if (Contains(renderable))
            {
                GameConsole.WriteLine(string.Format("{0}: Tried to add an renderable that is already contained (Name {1})", GetType().Name, renderable.GetType().Name), GameConsole.MessageType.Error); // Debug
                return(false);
            }

            // Add entity to container
            _renderables.Add(renderable);

            // Success
            return(true);
        }
Esempio n. 9
0
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                return;
            }
            if (currentShape != null)
            {
                undoElements = new UseCaseDiagramDocument(Elements);
                undoDone     = false;
                unselectShapes();
                currentShape.Selected = true;
                Elements.Add(currentShape);
                EnlargeIfNeeded(currentShape);
                currentShape = null;
                unselectToolStrips();
            }
            else
            {
                bool Moveflag        = false;
                bool resizeFlag      = false;
                bool lineFirstPoint  = false;
                bool anyShapeClicked = false;
                foreach (IDrawable obj in Elements.Elements)
                {
                    if (obj.IsFirstPointClicked(e.Location) && !ctrlDown)
                    {
                        undoElements        = new UseCaseDiagramDocument(Elements);
                        undoDone            = false;
                        firstPointDragStart = e.Location;
                        lineFirstPoint      = true;
                    }
                    else if (obj.IsResizeSquareClicked(e.Location) && !ctrlDown)
                    {
                        undoElements    = new UseCaseDiagramDocument(Elements);
                        undoDone        = false;
                        resizeDragStart = e.Location;
                        resizeFlag      = true;
                    }
                    else if (obj.Selected && obj.isClicked(e.Location) && !ctrlDown)
                    {
                        undoElements = new UseCaseDiagramDocument(Elements);
                        undoDone     = false;
                        Moveflag     = true;
                    }
                }
                if (!resizeFlag && !lineFirstPoint)
                {
                    if (Moveflag)
                    {
                        undoElements = new UseCaseDiagramDocument(Elements);
                        undoDone     = false;
                        dragStart    = e.Location;
                        this.Cursor  = Cursors.SizeAll;
                    }
                    else
                    {
                        Elements.Selected(e.Location, ctrlDown);
                    }
                }
                if (!ctrlDown && !Moveflag && !resizeFlag)
                {
                    foreach (IDrawable obj in Elements.Elements)
                    {
                        obj.isSelected(e.Location, false);
                        if (obj.Selected)
                        {
                            anyShapeClicked         = true;
                            previouslyShapeSelected = true;
                        }
                    }
                    if (!anyShapeClicked)
                    {
                        startPointSelectRectangle = e.Location;
                    }
                }
            }

            lastClickedShape = null;
            foreach (IDrawable obj in Elements.Elements)
            {
                if (obj.isClicked(e.Location))
                {
                    lastClickedShape = obj;
                }
            }
            if (lastClickedShape != null)
            {
                Point location = new Point(lastClickedShape.X, lastClickedShape.Y - 30);
                location.X -= panel1.HorizontalScroll.Value;
                location.Y -= panel1.VerticalScroll.Value;
                location.X  = Math.Max(location.X, 0);
                toolStripMobile.Location              = location;
                toolStripMobileChangeText.Text        = lastClickedShape.Text;
                toolStripMobilecbBorderWidth.Text     = lastClickedShape.BorderWidth.ToString();
                toolStripMobilebtnBorderColor.Enabled = true;
                toolStripMobilebtnFillColor.Enabled   = true;
                if (lastClickedShape.GetType() == typeof(Actor))
                {
                    toolStripMobilebtnBorderColor.Enabled = false;
                    toolStripMobilebtnFillColor.Enabled   = false;
                }
                else if (lastClickedShape.GetType() == typeof(Line))
                {
                    toolStripMobilebtnFillColor.Enabled = false;
                }
                toolStripMobile.Visible = true;
            }
            else
            {
                toolStripMobile.Visible = false;
            }

            Invalidate(true);
        }