Beispiel #1
0
        private static void ParseNeedleElementNode(XElement parent, out PanelElement element)
        {
            double[] location = ((string)parent.Element("Location")).Split(',').Select(double.Parse).ToArray();
            double[] origin   = ((string)parent.Element("Origin")).Split(',').Select(double.Parse).ToArray();

            element = new NeedleElement
            {
                LocationX           = location[0],
                LocationY           = location[1],
                Layer               = (int)parent.Element("Layer"),
                Subject             = ParseSubjectNode(parent.Element("Subject")),
                DaytimeImage        = (string)parent.Element("DaytimeImage"),
                NighttimeImage      = (string)parent.Element("NighttimeImage"),
                TransparentColor    = Color24.ParseHexColor((string)parent.Element("TransparentColor")),
                DefinedRadius       = (bool)parent.Element("DefinedRadius"),
                Radius              = (double)parent.Element("Radius"),
                Color               = Color24.ParseHexColor((string)parent.Element("Color")),
                DefinedOrigin       = (bool)parent.Element("DefinedOrigin"),
                OriginX             = origin[0],
                OriginY             = origin[1],
                InitialAngle        = (double)parent.Element("InitialAngle"),
                LastAngle           = (double)parent.Element("LastAngle"),
                Minimum             = (double)parent.Element("Minimum"),
                Maximum             = (double)parent.Element("Maximum"),
                DefinedNaturalFreq  = (bool)parent.Element("DefinedNaturalFreq"),
                NaturalFreq         = (double)parent.Element("NaturalFreq"),
                DefinedDampingRatio = (bool)parent.Element("DefinedDampingRatio"),
                DampingRatio        = (double)parent.Element("DampingRatio"),
                Backstop            = (bool)parent.Element("Backstop"),
                Smoothed            = (bool)parent.Element("Smoothed")
            };
        }
Beispiel #2
0
        private static void WritePanelElementNode(XElement parent, PanelElement element)
        {
            if (element is Models.Panels.PilotLampElement)
            {
                WritePilotLampElementNode(parent, (Models.Panels.PilotLampElement)element);
            }

            if (element is NeedleElement)
            {
                WriteNeedleElementNode(parent, (NeedleElement)element);
            }

            if (element is DigitalNumberElement)
            {
                WriteDigitalNumberElementNode(parent, (DigitalNumberElement)element);
            }

            if (element is DigitalGaugeElement)
            {
                WriteDigitalGaugeElementNode(parent, (DigitalGaugeElement)element);
            }

            if (element is LinearGaugeElement)
            {
                WriteLinearGaugeElementNode(parent, (LinearGaugeElement)element);
            }

            if (element is TimetableElement)
            {
                WriteTimetableElementNode(parent, (TimetableElement)element);
            }
        }
Beispiel #3
0
        //有 易于变化的算法,又有稳定的数据结构,会比较适合,因为访问者模式把 算法的操作,给抽象出来了
        //比如计算 访问,各个UI元素的深度,找出最小的深度,这个操作,变成一个DethpVisitor  就可以计算访问深度了;
        // 增加一个新的操作,或者算法,就相当于 增加一个新的访问者类
        static void Main(string[] args)
        {
            #region 男人和女人对于不同状态的反应的 例子
            //ObjectStructure o = new ObjectStructure();
            //o.Attach(new Man());
            //o.Attach(new Woman());
            //SuccessAct success = new SuccessAct();
            //o.Display(success);
            ////失败时的反应
            //FailAct fail = new FailAct();
            //o.Display(fail);
            //FallInLove fallInLove = new FallInLove();
            //o.Display(fallInLove);
            //Married married = new Married();
            //o.Display(married);


            #endregion

            #region  访问深度,计算深度的,的例子
            PanelElement plPanelElement = new PanelElement(0, 1000);
            PanelElement p2Element      = new PanelElement(1001, 5000);
            UIButton     uiButton       = new UIButton(10101, 5010);
            UISprite     uiSprite       = new UISprite(10102, 5011);

            DepthVisitor depthVisitor = new DepthVisitor();
            MyObjectStructure.Instance.VisitAll(depthVisitor);
            Console.WriteLine($"总共深度为:{depthVisitor.TotalDepth}最大深度的Element的Id是{depthVisitor.MaxBaseElement.Id}最大深度为:{depthVisitor.MaxBaseElement.Depth}");
            #endregion
        }
Beispiel #4
0
        private static void WritePanelElementNode(string fileName, XElement parent, PanelElement element)
        {
            if (element is PilotLampElement)
            {
                WritePilotLampElementNode(fileName, parent, (PilotLampElement)element);
            }

            if (element is NeedleElement)
            {
                WriteNeedleElementNode(fileName, parent, (NeedleElement)element);
            }

            if (element is DigitalNumberElement)
            {
                WriteDigitalNumberElementNode(fileName, parent, (DigitalNumberElement)element);
            }

            if (element is DigitalGaugeElement)
            {
                WriteDigitalGaugeElementNode(parent, (DigitalGaugeElement)element);
            }

            if (element is LinearGaugeElement)
            {
                WriteLinearGaugeElementNode(fileName, parent, (LinearGaugeElement)element);
            }

            if (element is TimetableElement)
            {
                WriteTimetableElementNode(parent, (TimetableElement)element);
            }
        }
Beispiel #5
0
        private static PanelElement ParsePanelElementNode(XElement parent)
        {
            PanelElement element = null;

            switch (parent.Name.LocalName)
            {
            case "PilotLamp":
                ParsePilotLampElementNode(parent, out element);
                break;

            case "Needle":
                ParseNeedleElementNode(parent, out element);
                break;

            case "DigitalNumber":
                ParseDigitalNumberElementNode(parent, out element);
                break;

            case "DigitalGauge":
                ParseDigitalGaugeElementNode(parent, out element);
                break;

            case "LinearGauge":
                ParseLinearGaugeElementNode(parent, out element);
                break;

            case "Timetable":
                ParseTimetableElementNode(parent, out element);
                break;
            }

            return(element);
        }
        public async Task PickFileAndAddClipAsync()
        {
            var picker = new FileOpenPicker
            {
                SuggestedStartLocation = PickerLocationId.Desktop,
            };

            AddTypesFilters(picker, Constants.VideoFormats);
            AddTypesFilters(picker, Constants.PhotoFormats);

            picker.ViewMode = PickerViewMode.Thumbnail;


            var pickedFile = await picker.PickSingleFileAsync();

            if (pickedFile != null)
            {
                PanelElement element = new PanelElement
                {
                    FileType    = PickedFileIsPicture(pickedFile) ? FileType.Picture : FileType.Video,
                    Name        = pickedFile.Name,
                    StorageFile = pickedFile
                };
                element.Clip = await AddClipAsync(pickedFile, element).ConfigureAwait(true);

                PanelElements.Add(element);
            }
        }
Beispiel #7
0
 static void ZoomFont(ElementCollection elements, ZoomFontInfo infos)
 {
     for (int i = 0; i < elements.Count; i++)
     {
         var         element     = elements[i];
         TextElement textElement = element as TextElement;
         if (textElement != null)
         {
             if (textElement.FontSize != 0f)
             {
                 textElement.FontSize *= infos.DeltaFactor;
             }
             else
             {
                 textElement.Font = infos.Zoom(textElement.Font);
             }
         }
         else
         {
             PanelElement panelElement = element as PanelElement;
             if (panelElement != null)
             {
                 ZoomFont(panelElement.Children, infos);
             }
         }
     }
 }
        private static async Task <MediaClip> AddClipAsync(StorageFile pickedFile, PanelElement element)
        {
            MediaClip clip;

            if (element.FileType == FileType.Picture)
            {
                using (StorageItemThumbnail thumbnail = await pickedFile.GetThumbnailAsync(ThumbnailMode.PicturesView))
                {
                    if (thumbnail != null)
                    {
                        BitmapImage bitmapImage = new BitmapImage();
                        bitmapImage.SetSource(thumbnail);

                        element.Thumbnail = bitmapImage;
                    }
                }
                clip = await MediaClip.CreateFromImageFileAsync(pickedFile, TimeSpan.FromSeconds(5));
            }
            else
            {
                using (StorageItemThumbnail thumbnail = await pickedFile.GetThumbnailAsync(ThumbnailMode.VideosView))
                {
                    if (thumbnail != null)
                    {
                        BitmapImage bitmapImage = new BitmapImage();
                        bitmapImage.SetSource(thumbnail);

                        element.Thumbnail = bitmapImage;
                    }
                }
                clip = await MediaClip.CreateFromFileAsync(pickedFile);
            }

            return(clip);
        }
Beispiel #9
0
        private void LoadSubmenu()
        {
            MainPanel = new Panel(GameConstants.Content.Load <Texture2D>("Panels/menu/MenuBG"), new Vector2(0, 0));
            // ptDiff, ptCol, ptCon, peCursor;

            ptSettings = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptSettings.AddText(GameConstants.lucidaConsole, "SETTINGS", Color.White, 1f);
            ptDiff = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptDiff.AddText(GameConstants.lucidaConsole, "Difficulty", Color.White, 2.2f);
            ptSound = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptSound.AddText(GameConstants.lucidaConsole, "Sound", Color.White, 2.2f);
            ptCon = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptCon.AddText(GameConstants.lucidaConsole, "Controls", Color.White, 2.2f);
            ptMBack = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptMBack.AddText(GameConstants.lucidaConsole, "Back", Color.White);
            ptDiff2 = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), false);
            ptDiff2.AddText(GameConstants.lucidaConsole, "Difficulty", Color.Red, 2.2f);
            ptSound2 = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), false);
            ptSound2.AddText(GameConstants.lucidaConsole, "Sound", Color.Red, 2.2f);
            ptCon2 = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), false);
            ptCon2.AddText(GameConstants.lucidaConsole, "Controls", Color.Red, 2.2f);
            peCursor = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/menu/cursor"), true);

            MainPanel.Add(ptSettings, new Vector2(0.05f, 0.05f));
            MainPanel.Add(ptDiff, new Vector2(0.1f, 0.3f));
            MainPanel.Add(ptSound, new Vector2(0.1f, 0.45f));
            MainPanel.Add(ptCon, new Vector2(0.1f, 0.6f));
            MainPanel.Add(ptDiff2, new Vector2(0.1f, 0.3f));
            MainPanel.Add(ptSound2, new Vector2(0.1f, 0.45f));
            MainPanel.Add(ptCon2, new Vector2(0.1f, 0.6f));
            MainPanel.Add(ptMBack, new Vector2(0.1f, 0.75f));
            // Can be 0.31 ; 0,46; 0,61; 0,76
            MainPanel.Add(peCursor, new Vector2(0.05f, 0.31f));
        }
Beispiel #10
0
        private void LoadPanel()
        {
            MainPanel = new Panel(GameConstants.Content.Load <Texture2D>("Panels/panel"),
                                  new Vector2(0.1f * GameConstants.WINDOWSIZE.X,
                                              0.1f * GameConstants.WINDOWSIZE.Y));

            peRdy        = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/Rdy"), true);
            pePressJump  = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/pressA"), true);
            pePressJump2 = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/pressB"), false);
            ptJump       = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptJump.AddText(GameConstants.lucidaConsole, "press space \n to Jump", Microsoft.Xna.Framework.Color.White);
            peJumpA = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/JumpA"), true);
            peJumpB = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/JumpB"), false);
            ptRun   = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptRun.AddText(GameConstants.lucidaConsole, "switch lane \n with arrow buttons", Microsoft.Xna.Framework.Color.White);
            peRunA = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/RunA"), false);
            peRunB = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/RunB"), true);


            //TODO: FIX THAT ptRUN and ptJump werent shown
            MainPanel.Add(peRdy, new Vector2(0.3f, 0.44f));
            MainPanel.Add(pePressJump, new Vector2(0.3f, 0.62f));
            MainPanel.Add(pePressJump2, new Vector2(0.3f, 0.62f));
            MainPanel.Add(peRunA, new Vector2(0.6f, 0.2f));
            MainPanel.Add(peRunB, new Vector2(0.6f, 0.2f));
            MainPanel.Add(ptRun, new Vector2(0.6f, 0.1f));
            MainPanel.Add(peJumpA, new Vector2(0.15f, 0.2f));
            MainPanel.Add(peJumpB, new Vector2(0.15f, 0.2f));
            MainPanel.Add(ptJump, new Vector2(0.15f, 0.1f));
        }
Beispiel #11
0
        private void initTileCategory()
        {
            TileCat      = new C1TileControl();
            TileCat.Dock = DockStyle.Fill;
            TileCat.Font = fEdit;

            TileCat.Orientation = LayoutOrientation.Horizontal;

            grRec = new Group();
            TileCat.Groups.Add(this.grRec);

            //peRec = new C1.Win.C1Tile.PanelElement();
            //ieRec = new C1.Win.C1Tile.ImageElement();
            tempRec                 = new C1.Win.C1Tile.Template();
            imageElementRec         = new C1.Win.C1Tile.ImageElement();
            peCat                   = new C1.Win.C1Tile.PanelElement();
            ieOrd                   = new C1.Win.C1Tile.ImageElement();
            teOrd                   = new TextElement();
            teOrd.Font              = fEdit;
            teCat                   = new TextElement();
            teCat.BackColorSelector = C1.Win.C1Tile.BackColorSelector.Unbound;
            teCat.ForeColor         = System.Drawing.Color.Black;
            teCat.ForeColorSelector = C1.Win.C1Tile.ForeColorSelector.Unbound;
            teCat.SingleLine        = true;

            imageElementRec.ImageLayout = C1.Win.C1Tile.ForeImageLayout.Stretch;
            //imageElementRec.
            //peOrd = new PanelElement();
            //peOrd.Alignment = System.Drawing.ContentAlignment.BottomLeft;
            //peOrd.Children.Add(ieOrd);
            //peOrd.Children.Add(teOrd);
            //peOrd.Margin = new System.Windows.Forms.Padding(10, 6, 10, 6);
            //peCat.BackColor = tileFoodsNameColor;
            peCat.Children.Add(teCat);
            peCat.Dock    = System.Windows.Forms.DockStyle.Top;
            peCat.Padding = new System.Windows.Forms.Padding(4, 2, 4, 2);

            //TileCat.DefaultTemplate.Elements.Add(peOrd);
            TileCat.Templates.Add(this.tempRec);
            tempRec.Elements.Add(imageElementRec);

            tempRec.Elements.Add(peCat);

            //tempRec.Elements.Add(pnFoodsPrice);
            tempRec.Name                    = "tempFlickrrec";
            TileCat.ScrollOffset            = 0;
            TileCat.SurfaceContentAlignment = System.Drawing.ContentAlignment.TopLeft;
            TileCat.Padding                 = new System.Windows.Forms.Padding(0);
            TileCat.GroupPadding            = new System.Windows.Forms.Padding(20);
            //TileCat.BackColor = tileCatColor;       // tab recommend color
            //TileCat.Templates.Add(this.tempRec);

            //pnTilImage.BackColor = tilecolor;
            pnTilImage.Controls.Add(TileCat);
            setTileCategory();
            //for (int i = 0; i < dtCat.Rows.Count; i++)
            //{
            //    LoadFoods(false, i, dtCat.Rows[i]["foods_cat_id"].ToString());
            //}
        }
Beispiel #12
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e?.Parameter != null)
     {
         PanelElement panelElement = (PanelElement)e.Parameter;
         ViewModel = new TrimPageViewModel(panelElement);
     }
 }
Beispiel #13
0
        public void LoadContent()
        {
            MainPanel = new Panel(GameConstants.Content.Load <Texture2D>("Panels/menu/MenuBG"), new Vector2(0, 0));

            peHeader = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/menu/creditscomplete"), true);
            //TODO: mit den einzelnen Elementen umsetzen, hier aus Faulheit ein großes .png für die Controls


            MainPanel.Add(peHeader, new Vector2(0.1f, 0.1f));
        }
Beispiel #14
0
 /// <summary>
 /// Test whether a PanelElement source object has a representation
 /// that can be written out as a mesh
 /// </summary>
 /// <returns></returns>
 public bool HasMeshRepresentation()
 {
     if (SourceObject is PanelElement)
     {
         PanelElement pEl = (PanelElement)SourceObject;
         if (pEl.Geometry is Mesh)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #15
0
        private void LoadControlsPanel()
        {
            ControlsPanel = new Panel(GameConstants.Content.Load <Texture2D>("Panels/menu/panelMenu"),
                                      new Vector2(0.35f * GameConstants.WINDOWSIZE.X,
                                                  0.1f * GameConstants.WINDOWSIZE.Y));

            ptHeader3 = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/menu/controlscomplete"), true);
            //TODO: mit den einzelnen Elementen umsetzen, hier aus Faulheit ein großes .png für die Controls


            ControlsPanel.Add(ptHeader3, new Vector2(0.1f, 0.1f));
        }
Beispiel #16
0
 public override bool HasSubComponentsToWrite(object source)
 {
     if (source is PanelElement)
     {
         PanelElement pEl = (PanelElement)source;
         if (pEl.Geometry is Mesh)
         {
             Mesh mesh = (Mesh)pEl.Geometry;
             return(mesh.Faces.Count > this.SubComponentIndex);
         }
     }
     return(base.HasSubComponentsToWrite(source));
 }
Beispiel #17
0
 /// <summary>
 /// Get the current sub-component mesh face of the current panel element
 /// source object
 /// </summary>
 /// <returns></returns>
 public MeshFace CurrentPanelFace()
 {
     if (SourceObject is PanelElement)
     {
         PanelElement el = (PanelElement)SourceObject;
         if (el.Geometry is Mesh)
         {
             Mesh mesh = (Mesh)el.Geometry;
             return(mesh.Faces[SubComponentIndex]);
         }
     }
     return(null);
 }
Beispiel #18
0
        public override bool Execute(ExecutionInfo exInfo = null)
        {
            if (Line != null && Line.Length > 0 && Height != 0)
            {
                var points = new Vector[] { Line.StartPoint, Line.EndPoint,
                                            Line.EndPoint + new Vector(0, 0, Height), Line.StartPoint + new Vector(0, 0, Height) };

                PlanarRegion pRegion = new PlanarRegion(new PolyLine(points, true));
                Element        = Model.Create.PanelElement(pRegion, exInfo);
                Element.Family = BuildUp;
            }
            return(true);
        }
        private void ReleaseClippingPath(SceneElement sceneElement, SceneEditTransaction editTransaction)
        {
            if (sceneElement.IsSet(Base2DElement.ClipProperty) != PropertyState.Set)
            {
                return;
            }
            SceneNode sceneNode = (SceneNode)sceneElement;

            for (SceneNode parent = sceneElement.Parent; parent != null; parent = parent.Parent)
            {
                PanelElement panelElement = parent as PanelElement;
                if (panelElement != null)
                {
                    MatrixTransform matrixTransform        = new MatrixTransform(sceneElement.GetComputedTransformToElement((SceneElement)panelElement));
                    PathGeometry    pathGeometry1          = new PathGeometry();
                    System.Windows.Media.Geometry geometry = (System.Windows.Media.Geometry)sceneElement.GetLocalOrDefaultValueAsWpf(Base2DElement.ClipProperty);
                    if (geometry != null)
                    {
                        pathGeometry1 = PathGeometryUtilities.TransformGeometry(geometry, (Transform)matrixTransform);
                    }
                    PathElement pathElement = (PathElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Path);
                    using (pathElement.ViewModel.ForceBaseValue())
                    {
                        this.DesignerContext.AmbientPropertyManager.ApplyAmbientProperties((SceneNode)pathElement);
                        pathElement.SetValueAsWpf(ShapeElement.StrokeProperty, (object)Brushes.Black);
                        pathElement.ClearValue(ShapeElement.FillProperty);
                        pathElement.ClearValue(ShapeElement.StrokeThicknessProperty);
                        panelElement.Children.Insert(panelElement.Children.IndexOf(sceneNode) + 1, (SceneNode)pathElement);
                        ReferenceStep singleStep1 = (ReferenceStep)pathElement.ProjectContext.ResolveProperty(Base2DElement.ClipProperty);
                        ReferenceStep singleStep2 = (ReferenceStep)pathElement.ProjectContext.ResolveProperty(PathElement.DataProperty);
                        PathCommandHelper.MoveVertexAnimations(sceneElement, new PropertyReference(singleStep1), (SceneElement)pathElement, new PropertyReference(singleStep2), (Transform)matrixTransform);
                        Rect bounds            = PathCommandHelper.InflateRectByStrokeWidth(pathGeometry1.Bounds, pathElement, false);
                        Rect maxAnimatedExtent = PathCommandHelper.FindMaxAnimatedExtent((SceneElement)pathElement, bounds, new PropertyReference(singleStep2));
                        editTransaction.Update();
                        Vector vector = new Vector(-maxAnimatedExtent.Left, -maxAnimatedExtent.Top);
                        panelElement.LayoutDesigner.SetChildRect((BaseFrameworkElement)pathElement, maxAnimatedExtent);
                        Transform    transform     = (Transform) new TranslateTransform(vector.X, vector.Y);
                        PathGeometry pathGeometry2 = PathGeometryUtilities.TransformGeometry((System.Windows.Media.Geometry)pathGeometry1, transform);
                        pathElement.PathGeometry = pathGeometry2;
                        PathCommandHelper.TransformPointKeyframes((SceneElement)pathElement, new PropertyReference(singleStep2), transform);
                        pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)(Stretch)(pathElement.HasVertexAnimations ? 0 : 1));
                        break;
                    }
                }
                else
                {
                    sceneNode = parent;
                }
            }
        }
Beispiel #20
0
 public override bool Execute(ExecutionInfo exInfo = null)
 {
     if (Perimeter != null && Perimeter.Plane() != null)
     {
         PlanarRegion pRegion = new PlanarRegion(Perimeter);
         Element        = Model.Create.PanelElement(pRegion, exInfo);
         Element.Family = BuildUp;
         return(true);
     }
     else
     {
         throw new Exception("Input curve is not planar!");
     }
 }
Beispiel #21
0
        private static void ParseTimetableElementNode(XElement parent, out PanelElement element)
        {
            double[] location = ((string)parent.Element("Location")).Split(',').Select(double.Parse).ToArray();

            element = new TimetableElement
            {
                LocationX        = location[0],
                LocationY        = location[1],
                Layer            = (int)parent.Element("Layer"),
                Width            = (double)parent.Element("Width"),
                Height           = (double)parent.Element("Height"),
                TransparentColor = Color24.ParseHexColor((string)parent.Element("TransparentColor"))
            };
        }
        private void AddPresenterIfNecessary(DocumentCompositeNode visualTreeNode, SceneElement newElement)
        {
            Type targetType = (Type)null;

            if (PlatformTypes.ContentControl.IsAssignableFrom((ITypeId)newElement.Type))
            {
                targetType = newElement.ViewModel.ProjectContext.ResolveType(PlatformTypes.ContentPresenter).RuntimeType;
            }
            else if (PlatformTypes.ItemsControl.IsAssignableFrom((ITypeId)newElement.Type))
            {
                targetType = newElement.ViewModel.ProjectContext.ResolveType(PlatformTypes.ItemsPresenter).RuntimeType;
            }
            if (!(targetType != (Type)null))
            {
                return;
            }
            DocumentNode node = visualTreeNode.SelectFirstDescendantNode(targetType);

            if (node == null)
            {
                PanelElement panelElement     = (PanelElement)this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode);
                SceneElement presenterElement = (SceneElement)this.SceneViewModel.CreateSceneNode(targetType);
                SceneElement sceneElement     = this.PreparePresenter(visualTreeNode, presenterElement);
                GridElement  gridElement      = panelElement as GridElement;
                if (gridElement != null)
                {
                    int count1 = gridElement.ColumnDefinitions.Count;
                    int count2 = gridElement.RowDefinitions.Count;
                    if (count1 > 0)
                    {
                        sceneElement.SetLocalValue(GridElement.ColumnSpanProperty, (object)count1);
                    }
                    if (count2 > 0)
                    {
                        sceneElement.SetLocalValue(GridElement.RowSpanProperty, (object)count2);
                    }
                }
                panelElement.Children.Add((SceneNode)sceneElement);
            }
            else
            {
                SceneElement presenterElement = this.SceneViewModel.GetSceneNode(node) as SceneElement;
                if (presenterElement == null)
                {
                    return;
                }
                this.PreparePresenter(visualTreeNode, presenterElement);
            }
        }
Beispiel #23
0
        private static void ParsePilotLampElementNode(XElement parent, out PanelElement element)
        {
            double[] location = ((string)parent.Element("Location")).Split(',').Select(double.Parse).ToArray();

            element = new Models.Panels.PilotLampElement
            {
                LocationX        = location[0],
                LocationY        = location[1],
                Layer            = (int)parent.Element("Layer"),
                Subject          = ParseSubjectNode(parent.Element("Subject")),
                DaytimeImage     = (string)parent.Element("DaytimeImage"),
                NighttimeImage   = (string)parent.Element("NighttimeImage"),
                TransparentColor = Color24.ParseHexColor((string)parent.Element("TransparentColor"))
            };
        }
 public Navigator UseWindow(int windowIndex)
 {
     _windowId = windowIndex;
     _container = _runningApp.GetWindows()[windowIndex];
     _button = null;
     _checkBox = null;
     _label = null;
     _radioButton = null;
     _textBox = null;
     _comboBox = null;
     _image = null;
     _tab = null;
     _treeView = null;
     _panel = null;
     return this;
 }
Beispiel #25
0
        private void LoadDifficultyPanel()
        {
            DifficultyPanel = new Panel(GameConstants.Content.Load <Texture2D>("Panels/menu/panelMenu"),
                                        new Vector2(0.35f * GameConstants.WINDOWSIZE.X,
                                                    0.1f * GameConstants.WINDOWSIZE.Y));


            ptHeader = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptHeader.AddText(GameConstants.lucidaConsole, "Difficulty", Color.White);
            peEnter = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/menu/Enter"), true);
            peEsc   = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/menu/esc"), true);
            ptBack  = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true); // Text: number of Coins
            ptBack.AddText(GameConstants.lucidaConsole, "Back", Color.White);
            ptConfirm = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptConfirm.AddText(GameConstants.lucidaConsole, "Confirm", Color.White);

            ptEasy = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptEasy.AddText(GameConstants.lucidaConsole, "easy", Color.White, 2.2f);
            ptExtreme = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptExtreme.AddText(GameConstants.lucidaConsole, "extreme", Color.Violet, 2.2f);
            ptHard = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptHard.AddText(GameConstants.lucidaConsole, "hard", Color.White, 2.2f);
            ptMedium = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), true);
            ptMedium.AddText(GameConstants.lucidaConsole, "medium", Color.White);
            ptEasy2 = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), false);
            ptEasy2.AddText(GameConstants.lucidaConsole, "easy", Color.Red, 2.2f);
            ptExtreme2 = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), false);
            ptExtreme2.AddText(GameConstants.lucidaConsole, "extreme", Color.Red, 2.2f);
            ptHard2 = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), false);
            ptHard2.AddText(GameConstants.lucidaConsole, "hard", Color.Red, 2.2f);
            ptMedium2 = new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/void"), false);
            ptMedium2.AddText(GameConstants.lucidaConsole, "medium", Color.Red);

            DifficultyPanel.Add(ptHeader, new Vector2(0.1f, 0.1f));
            DifficultyPanel.Add(peEnter, new Vector2(0.13f, 0.8f));
            DifficultyPanel.Add(ptConfirm, new Vector2(0.25f, 0.8f));
            DifficultyPanel.Add(peEsc, new Vector2(0.7f, 0.8f));
            DifficultyPanel.Add(ptBack, new Vector2(0.82f, 0.8f));
            DifficultyPanel.Add(ptEasy, new Vector2(0.4f, 0.2f));
            DifficultyPanel.Add(ptEasy2, new Vector2(0.4f, 0.2f));
            DifficultyPanel.Add(ptMedium, new Vector2(0.4f, 0.34f));
            DifficultyPanel.Add(ptMedium2, new Vector2(0.4f, 0.34f));
            DifficultyPanel.Add(ptHard, new Vector2(0.4f, 0.48f));
            DifficultyPanel.Add(ptHard2, new Vector2(0.4f, 0.48f));
            DifficultyPanel.Add(ptExtreme, new Vector2(0.4f, 0.62f));
            DifficultyPanel.Add(ptExtreme2, new Vector2(0.4f, 0.62f));
        }
Beispiel #26
0
        private void LoadQuestionPanel()
        {
            Panel = new Panel(GameConstants.Content.Load <Texture2D>("Panels/panel"),
                              new Vector2(0.1f * GameConstants.WINDOWSIZE.X,
                                          0.1f * GameConstants.WINDOWSIZE.Y));

            yes = new PanelElement("yes", GameConstants.lucidaConsole, Color.Red, true);
            no  = new PanelElement("no", GameConstants.lucidaConsole, Color.Red, false);

            Panel.Add(new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/newGame")), new Vector2(0.08f, 0.18f));
            Panel.Add(new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/button")), new Vector2(0.2f, 0.75f));
            Panel.Add(new PanelElement("yes", GameConstants.lucidaConsole, Color.White), new Vector2(0.25f, 0.75f));
            Panel.Add(yes, new Vector2(0.25f, 0.75f));
            Panel.Add(new PanelElement(GameConstants.Content.Load <Texture2D>("Panels/button")), new Vector2(0.60f, 0.75f));
            Panel.Add(new PanelElement("no", GameConstants.lucidaConsole, Color.White), new Vector2(0.67f, 0.75f));
            Panel.Add(no, new Vector2(0.67f, 0.75f));
        }
Beispiel #27
0
        public override bool Execute(ExecutionInfo exInfo = null)
        {
            Elements = new ElementCollection();

            if (Geometry != null)
            {
                // Convert each geometry item:
                foreach (VertexGeometry shape in Geometry)
                {
                    if (shape is Curve) // Convert to linear element
                    {
                        LinearElement element = Model.Create.LinearElement((Curve)shape, exInfo);
                        if (FamiliesFromLayers && shape.Attributes != null && !string.IsNullOrWhiteSpace(shape.Attributes.LayerName))
                        {
                            string        layerName = shape.Attributes.LayerName;
                            SectionFamily sF        = Model.Families.Sections.FindByName(layerName);
                            if (sF == null)
                            {
                                sF = Model.Create.SectionFamily(layerName, exInfo);
                            }
                            element.Family = sF;
                        }
                        Elements.Add(element);
                    }
                    else if (shape is Surface) //Reminder: Meshes are also surfaces!
                    {
                        PanelElement element = Model.Create.PanelElement((Surface)shape, exInfo);
                        if (FamiliesFromLayers && shape.Attributes != null && !string.IsNullOrWhiteSpace(shape.Attributes.LayerName))
                        {
                            string        layerName = shape.Attributes.LayerName;
                            BuildUpFamily fF        = Model.Families.PanelFamilies.FindByName(layerName);
                            if (fF == null)
                            {
                                fF = Model.Create.BuildUpFamily(layerName, exInfo);
                            }
                            element.Family = fF;
                        }
                        Elements.Add(element);
                    }
                }
                Elements.GenerateNodes(new NodeGenerationParameters());
                return(true);
            }
            return(false);
        }
        internal PanelElementViewModel(PanelElement element)
        {
            CultureInfo culture = CultureInfo.InvariantCulture;

            LocationX = element
                        .ToReactivePropertyAsSynchronized(
                x => x.LocationX,
                x => x.ToString(culture),
                x => double.Parse(x, NumberStyles.Float, culture),
                ignoreValidationErrorValue: true
                )
                        .SetValidateNotifyError(x =>
            {
                double result;
                string message;

                Utilities.TryParse(x, NumberRange.Any, out result, out message);

                return(message);
            })
                        .AddTo(disposable);

            LocationY = element
                        .ToReactivePropertyAsSynchronized(
                x => x.LocationY,
                x => x.ToString(culture),
                x => double.Parse(x, NumberStyles.Float, culture),
                ignoreValidationErrorValue: true
                )
                        .SetValidateNotifyError(x =>
            {
                double result;
                string message;

                Utilities.TryParse(x, NumberRange.Any, out result, out message);

                return(message);
            })
                        .AddTo(disposable);

            Layer = element
                    .ToReactivePropertyAsSynchronized(x => x.Layer)
                    .AddTo(disposable);
        }
Beispiel #29
0
        private static void ParseDigitalGaugeElementNode(XElement parent, out PanelElement element)
        {
            double[] location = ((string)parent.Element("Location")).Split(',').Select(double.Parse).ToArray();

            element = new DigitalGaugeElement
            {
                LocationX    = location[0],
                LocationY    = location[1],
                Layer        = (int)parent.Element("Layer"),
                Subject      = ParseSubjectNode(parent.Element("Subject")),
                Radius       = (double)parent.Element("Radius"),
                Color        = Color24.ParseHexColor((string)parent.Element("Color")),
                InitialAngle = (double)parent.Element("InitialAngle"),
                LastAngle    = (double)parent.Element("LastAngle"),
                Minimum      = (double)parent.Element("Minimum"),
                Maximum      = (double)parent.Element("Maximum"),
                Step         = (double)parent.Element("Step")
            };
        }
Beispiel #30
0
        public TrimPageViewModel(PanelElement panelElement)
        {
            if (panelElement != null)
            {
                if (composition == null)
                {
                    composition = new MediaComposition();
                    composition.Clips.Add(panelElement.Clip);
                }

                PanelElement      = panelElement;
                PanelElement.Clip = panelElement.Clip.Clone();
                MediaSource       = panelElement.GetMediaSource();
                Min     = 0;
                Max     = panelElement.Clip.OriginalDuration.TotalSeconds;
                minTrim = PanelElement.Clip.TrimTimeFromStart.TotalSeconds;
                maxTrim = Math.Abs(PanelElement.Clip.TrimTimeFromEnd.TotalSeconds - PanelElement.Clip.OriginalDuration.TotalSeconds);
            }
        }
 public override bool Execute(ExecutionInfo exInfo = null)
 {
     if (Points != null && Points.Count > 2)
     {
         if (!Points.ArePlanar())
         {
             throw new Exception("Points do not lie on the same plane!");
         }
         // TODO: Check for re-entrancy!
         PlanarRegion pRegion = new PlanarRegion(new PolyLine(Points, true));
         Element        = Model.Create.PanelElement(pRegion, exInfo);
         Element.Family = BuildUp;
         return(true);
     }
     else
     {
         throw new Exception("Insufficient points to define a panel!");
     }
 }
 public PanelElement Panel()
 {
     return _panel ?? (_panel = new PanelElement(_container));
 }