Exemple #1
0
        private void Insert2Canvas(IWidget widget)
        {
            WidgetViewModBase vmItem;

            switch (widget.WidgetType)
            {
            case WidgetType.Button:
            {
                vmItem = new ButtonWidgetViewModel(widget);
                break;
            }

            case WidgetType.Image:
            {
                vmItem = new ImageWidgetViewModel(widget);
                break;
            }

            case WidgetType.FlowShape:
            {
                IFlowShape shape = widget as IFlowShape;
                if (shape.FlowShapeType == FlowShapeType.Diamond)
                {
                    vmItem = new DiamondWidgetViewModel(widget);
                }
                else if (shape.FlowShapeType == FlowShapeType.Ellipse)
                {
                    vmItem = new CircleWidgetViewModel(widget);
                }
                else if (shape.FlowShapeType == FlowShapeType.Rectangle)
                {
                    vmItem = new RectangleWidgetViewModel(widget);
                }
                else
                {
                    vmItem = new ImageWidgetViewModel(widget);
                }
                break;
            }

            default:
            {
                vmItem = new ImageWidgetViewModel(widget);
                break;
            }
            }
            vmItem.IsSelected = true;
            Items.Add(vmItem);
        }
Exemple #2
0
        //Create Widget VM According to XML data
        public static WidgetViewModBase CreateWidget(IRegion obj)
        {
            //string timeStamp = "_" + DateTime.Now.ToString("MMddHHmmssfff");
            WidgetViewModBase vmItem;

            if (obj is IMaster)
            {
                IMaster master = obj as IMaster;
                AutoSetWdgName(obj, "Master ", WidgetType.None);
                vmItem = new MasterWidgetViewModel(master);
                return(vmItem);
            }

            IWidget it = obj as IWidget;

            switch (it.WidgetType)
            {
            case WidgetType.Button:
            {
                AutoSetWdgName(it, "Button ", WidgetType.Button);
                vmItem = new ButtonWidgetViewModel(it);
                break;
            }

            case WidgetType.Image:
            {
                AutoSetWdgName(it, "Image ", WidgetType.Image);
                vmItem = new ImageWidgetViewModel(it);
                break;
            }

            case WidgetType.SVG:
            {
                AutoSetWdgName(it, "Svg ", WidgetType.SVG);
                vmItem = new SVGWidgetViewModel(it);
                break;
            }

            case WidgetType.HotSpot:
            {
                AutoSetWdgName(it, "Link ", WidgetType.HotSpot);
                vmItem = new HotSpotWidgetViewModel(it);
                break;
            }

            case WidgetType.Line:
            {
                ILine line = it as ILine;
                if (line.Orientation == Orientation.Vertical)
                {
                    AutoSetWdgName(it, "VLine ", WidgetType.Line);
                    vmItem = new VLineWidgetViewModel(it);
                }
                else
                {
                    AutoSetWdgName(it, "HLine ", WidgetType.Line);
                    vmItem = new HLineWidgetViewModel(it);
                }
                break;
            }

            case WidgetType.Shape:
            {
                IShape shape = it as IShape;
                if (shape.ShapeType == ShapeType.Diamond)
                {
                    AutoSetWdgName(it, "Diamond ", WidgetType.Shape);
                    vmItem = new DiamondWidgetViewModel(it);
                }
                else if (shape.ShapeType == ShapeType.Ellipse)
                {
                    AutoSetWdgName(it, "Ellipse ", WidgetType.Shape);
                    vmItem = new CircleWidgetViewModel(it);
                }
                else if (shape.ShapeType == ShapeType.Rectangle)
                {
                    AutoSetWdgName(it, "Rectangle ", WidgetType.Shape);
                    vmItem = new RectangleWidgetViewModel(it);
                }
                else if (shape.ShapeType == ShapeType.RoundedRectangle)
                {
                    AutoSetWdgName(it, "Round ", WidgetType.Shape);
                    vmItem = new RoundedRecWidgetViewModel(it);
                }
                else if (shape.ShapeType == ShapeType.Paragraph)
                {
                    AutoSetWdgName(it, "Paragraph ", WidgetType.Shape);
                    vmItem = new LabelWidgetViewModel(it);
                }
                else if (shape.ShapeType == ShapeType.Triangle)
                {
                    AutoSetWdgName(it, "Triangle ", WidgetType.Shape);
                    vmItem = new TriangleWidgetViewModel(it);
                }
                else
                {
                    AutoSetWdgName(it, "Image ", WidgetType.Shape);
                    vmItem = new ImageWidgetViewModel(it);
                }

                break;
            }

            case WidgetType.ListBox:
            {
                AutoSetWdgName(it, "ListBox ", WidgetType.ListBox);
                vmItem = new ListboxWidgetViewModel(it);
                break;
            }

            case WidgetType.DropList:
            {
                AutoSetWdgName(it, "DropList ", WidgetType.DropList);
                vmItem = new DroplistWidgetViewModel(it);
                break;
            }

            case WidgetType.Checkbox:
            {
                AutoSetWdgName(it, "Checkbox ", WidgetType.Checkbox);
                vmItem = new CheckBoxWidgetViewModel(it);
                break;
            }

            case WidgetType.RadioButton:
            {
                AutoSetWdgName(it, "RadioButton ", WidgetType.RadioButton);
                vmItem = new RadioButtonWidgetViewModel(it);
                break;
            }

            case WidgetType.TextArea:
            {
                AutoSetWdgName(it, "TextArea ", WidgetType.TextArea);
                vmItem = new TextAreaWidgetViewModel(it);
                break;
            }

            case WidgetType.TextField:
            {
                AutoSetWdgName(it, "TextField ", WidgetType.TextField);
                vmItem = new TextFieldWidgetViewModel(it);
                break;
            }

            case WidgetType.HamburgerMenu:
            {
                AutoSetWdgName(it, "Drawer ", WidgetType.HamburgerMenu);
                vmItem = new HamburgerMenuViewModel(it);
                break;
            }

            case WidgetType.DynamicPanel:
            {
                AutoSetWdgName(it, "Flicking ", WidgetType.DynamicPanel);
                vmItem = new DynamicPanelViewModel(it);
                break;
            }

            case WidgetType.Toast:
            {
                AutoSetWdgName(it, "Toast ", WidgetType.Toast);
                vmItem = new ToastViewModel(it);
                break;
            }

            case WidgetType.FlowShape:
                // To avoid crash when load old file as we don't support flow shape right now.
                // This is temporary code and remove it once we support flow shape.
                return(null);

            case WidgetType.None:
                return(null);

            default:
            {
                vmItem = null;
                break;
            }
            }//switch
            return(vmItem);
        }