示例#1
0
        public FlightData GetCurrentData()
        {
            var dataType = typeof(BMS4FlightData);

            if (_hPrimarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                ConnectToFalcon();
            }
            if (_hPrimarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                return(null);
            }

            var data     = Convert.ChangeType(Marshal.PtrToStructure(_lpPrimarySharedMemoryAreaBaseAddress, dataType), dataType);
            var toReturn = new FlightData((BMS4FlightData)data);

            if (!_hSecondarySharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (FlightData2)(Marshal.PtrToStructure(_lpSecondarySharedMemoryAreaBaseAddress, typeof(FlightData2)));
                toReturn.PopulateFromStruct(data);
            }

            if (!_hOsbSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (OSBData)(Marshal.PtrToStructure(_lpOsbSharedMemoryAreaBaseAddress, typeof(OSBData)));
                toReturn.PopulateFromStruct(data);
            }

            if (!_hIntelliVibeSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (IntellivibeData)(Marshal.PtrToStructure(_lpIntelliVibeSharedMemoryAreaBaseAddress, typeof(IntellivibeData)));
                toReturn.IntellivibeData = (IntellivibeData)data;
            }

            if (!_hRadioClientControlSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (RadioClientControl)(Marshal.PtrToStructure(_lpRadioClientControlSharedMemoryAreaBaseAddress, typeof(RadioClientControl)));
                toReturn.RadioClientControlData = (RadioClientControl)data;
            }

            if (!_hRadioClientStatusSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                data = (RadioClientStatus)(Marshal.PtrToStructure(_lpRadioClientStatusSharedMemoryAreaBaseAddress, typeof(RadioClientStatus)));
                toReturn.RadioClientStatus = (RadioClientStatus)data;
            }

            if (!_hStringSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                var rawStringData = GetRawStringData(toReturn.StringAreaSize);
                toReturn.StringData = StringData.GetStringData(rawStringData);
            }

            if (!_hDrawingSharedMemoryAreaFileMappingObject.Equals(IntPtr.Zero))
            {
                var rawDrawingData = GetRawDrawingData(toReturn.DrawingAreaSize);
                toReturn.DrawingData = DrawingData.GetDrawingData(rawDrawingData);
            }

            return(toReturn);
        }
示例#2
0
        protected void DrawUnwalkableNodes(DrawingData gizmos, float size, RedrawScope redrawScope)
        {
            var hasher = DrawingData.Hasher.Create(this);

            GetNodes(node => {
                hasher.Add(node.Walkable);
                if (!node.Walkable)
                {
                    hasher.Add(node.position);
                }
            });

            if (!gizmos.Draw(hasher, redrawScope))
            {
                using (var builder = gizmos.GetBuilder(hasher)) {
                    using (builder.WithColor(AstarColor.UnwalkableNode)) {
                        GetNodes(node => {
                            if (!node.Walkable)
                            {
                                builder.SolidBox((Vector3)node.position, new Unity.Mathematics.float3(size, size, size));
                            }
                        });
                    }
                }
            }
        }
示例#3
0
        /**
         * Constructor
         *
         * @param w The workbook to interrogate
         * @param out The output stream to which the CSV values are written
         * @param encoding The encoding used by the output stream.  Null or
         * unrecognized values cause the encoding to default to UTF8
         * @exception java.io.IOException
         */
        public Escher(Workbook w, TextWriter os, string encoding)
        {
            if (encoding == null || encoding == "UnicodeBig")
            {
                encoding = "UTF8";
            }

            try
            {
                for (int i = 0; i < w.getNumberOfSheets(); i++)
                {
                    SheetImpl s = (SheetImpl)w.getSheet(i);
                    os.Write(s.getName());
                    os.WriteLine();
                    os.WriteLine();

                    DrawingData dd = s.getDrawingData();

                    if (dd != null)
                    {
                        EscherDisplay ed = new EscherDisplay(dd, os);
                        ed.display();
                    }

                    os.WriteLine();
                    os.WriteLine();
                    os.Flush();
                }
                os.Flush();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
示例#4
0
        /// <summary>Draw gizmos for the graph</summary>
        public virtual void OnDrawGizmos(DrawingData gizmos, bool drawNodes, RedrawScope redrawScope)
        {
            if (!drawNodes)
            {
                return;
            }

            // This is a relatively slow default implementation.
            // subclasses of the base graph class may override
            // this method to draw gizmos in a more optimized way

            var hasher = new NodeHasher(active);

            GetNodes(node => hasher.HashNode(node));

            // Update the gizmo mesh if necessary
            if (!gizmos.Draw(hasher, redrawScope))
            {
                using (var helper = GraphGizmoHelper.GetGizmoHelper(gizmos, active, hasher, redrawScope)) {
                    GetNodes((System.Action <GraphNode>)helper.DrawConnections);
                }
            }

            if (active.showUnwalkableNodes)
            {
                DrawUnwalkableNodes(gizmos, active.unwalkableNodeDebugSize, redrawScope);
            }
        }
示例#5
0
    public void SetImage(DrawingData drawing)
    {
        SetBrushColor(drawing.Creator.RoomId);
        var image = Convert.FromBase64String(drawing.Image);

        SetImage(image);
    }
示例#6
0
        public override void OnDrawGizmos(DrawingData gizmos, bool drawNodes, RedrawScope redrawScope)
        {
            base.OnDrawGizmos(gizmos, drawNodes, redrawScope);

            if (!drawNodes)
            {
                return;
            }

            using (var draw = gizmos.GetBuilder()) {
                using (draw.WithColor(new Color(0.161f, 0.341f, 1f, 0.5f))) {
                    if (root != null)
                    {
                        DrawChildren(draw, this, root);
                    }
                    else if (!string.IsNullOrEmpty(searchTag))
                    {
                        GameObject[] gos = GameObject.FindGameObjectsWithTag(searchTag);
                        for (int i = 0; i < gos.Length; i++)
                        {
                            draw.SolidBox(gos[i].transform.position, Vector3.one * UnityEditor.HandleUtility.GetHandleSize(gos[i].transform.position) * 0.1F);
                        }
                    }
                }
            }
        }
        public void REMOVEREVLINE(Settings settings, DrawingData drawingData, string RevToDel)
        {
            string     attbValue      = "";
            int        RevIndex       = 1;
            var        AM             = new AttributeManager();
            List <int> revIndexToMove = new List <int>();
            bool       revFound       = false;


            //Avgjør revisjonsindex i gjeldende tegning.
            for (int i = 1; i < 7; i++)
            {
                if (AM.CHECKATTRIBUTEVALUE(settings.RevBlockName.ToUpper(), "REV" + i) == RevToDel)
                {
                    RevIndex = i;
                    revFound = true;
                    break;
                }
            }

            //Fjerner revisjonslinjen hvis den ble funnet.
            if (revFound)
            {
                foreach (var attributeName in settings.PropertyNameList)
                {
                    AM.UPDATEATTRIBUTESINDATABASE(
                        settings.RevBlockName.ToUpper(),
                        attributeName + RevIndex,
                        attbValue
                        );
                }
            }
        }
示例#8
0
        private MapData GetMapData(int group, int drawing, int map)
        {
            GroupData   groupData   = groupsDataInitializer.Data.Groups[group];
            DrawingData drawingData = groupData.Drawings[drawing];

            return(drawingData.Maps[map]);
        }
示例#9
0
        public static GraphGizmoHelper GetGizmoHelper(DrawingData gizmos, AstarPath active, DrawingData.Hasher hasher, RedrawScope redrawScope)
        {
            var helper = ObjectPool <GraphGizmoHelper> .Claim();

            helper.Init(active, hasher, gizmos, redrawScope);
            return(helper);
        }
示例#10
0
        /// <summary>
        /// Draws a mesh with a shadow map drawer
        /// </summary>
        /// <param name="effect">Effect</param>
        /// <param name="drawingData">Drawing data</param>
        /// <param name="meshName">Mesh name</param>
        /// <param name="index">Instance buffer index</param>
        /// <param name="length">Instance buffer length</param>
        /// <returns>Returns the number of drawn triangles</returns>
        private int DrawMeshShadow(IShadowMapDrawer effect, DrawingData drawingData, string meshName, int index, int length)
        {
            int count = 0;

            var graphics = this.Game.Graphics;

            var meshDict = drawingData.Meshes[meshName];

            foreach (string materialName in meshDict.Keys)
            {
                var mesh     = meshDict[materialName];
                var material = drawingData.Materials[materialName];

                count += mesh.IndexBuffer.Count > 0 ? mesh.IndexBuffer.Count / 3 : mesh.VertexBuffer.Count / 3;

                effect.UpdatePerObject(0, material, 0);

                this.BufferManager.SetIndexBuffer(mesh.IndexBuffer.Slot);

                var technique = effect.GetTechnique(mesh.VertextType, true, material.Material.IsTransparent);
                this.BufferManager.SetInputAssembler(technique, mesh.VertexBuffer.Slot, mesh.Topology);

                for (int p = 0; p < technique.PassCount; p++)
                {
                    graphics.EffectPassApply(technique, p, 0);

                    mesh.Draw(graphics, index, length);
                }
            }

            return(count);
        }
示例#11
0
 /// <summary>
 /// Dispose resources
 /// </summary>
 /// <param name="disposing">Free managed resources</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.DrawingData?.Dispose();
         this.DrawingData = null;
     }
 }
        public DebugCanvasComponent()
        {
            InitializeComponent();

            DrawingData = new DrawingData();
            _renderer   = new GdiRenderer(s =>
            {
                imgMain.Source = s;
            });
        }
示例#13
0
        public override void UpdateButton(ButtonController button)
        {
            GroupData   groupData   = groupsDataInitializer.Data.Groups[progressController.GroupIndex];
            DrawingData drawingData = groupData.Drawings[button.Id];

            GroupProgressData   groupProgressData   = progressController.GetGroupData(progressController.GroupIndex);
            DrawingProgressData drawingProgressData = groupProgressData.Drawings[button.Id];

            DrawingButtonController buttonController = button.GetComponent <DrawingButtonController>();

            buttonController.Init(button.Id, themeController.GetCurrentTheme(), drawingData, drawingProgressData);
        }
示例#14
0
        private void Form1_MouseUp(object sender, MouseEventArgs e)
        {
            if (mousePressdDown == 1)
            {
                label1.Text = "X: " + mouseMovePosition.X.ToString();
                label2.Text = "Y: " + mouseMovePosition.Y.ToString();
                this.Invalidate();
            }
            DrawingData a = new DrawingData(mouseMovePosition, mouseDownPosition, rnd.Next().ToString());

            drawnItemsList.Add(a);
            mousePressdDown = 0;
        }
示例#15
0
        /// <summary>
        /// Updates instancing data buffer
        /// </summary>
        /// <param name="context">Update context</param>
        private void UpdateInstancingData(UpdateContext context)
        {
            if (!this.instancesTmp.Any())
            {
                return;
            }

            this.SortInstances(context.EyePosition);

            LevelOfDetail lastLod       = LevelOfDetail.None;
            DrawingData   drawingData   = null;
            int           instanceIndex = 0;

            for (int i = 0; i < this.instancesTmp.Length; i++)
            {
                var current = this.instancesTmp[i];
                if (current == null)
                {
                    continue;
                }

                if (lastLod != current.LevelOfDetail)
                {
                    lastLod     = current.LevelOfDetail;
                    drawingData = this.GetDrawingData(lastLod);
                }

                uint animationOffset = 0;

                if (drawingData?.SkinningData != null)
                {
                    if (current.AnimationController.Playing)
                    {
                        current.InvalidateCache();
                    }

                    current.AnimationController.Update(context.GameTime.ElapsedSeconds, drawingData.SkinningData);
                    animationOffset = current.AnimationController.GetAnimationOffset(drawingData.SkinningData);
                }

                this.instancingData[instanceIndex].Local           = current.Manipulator.LocalTransform;
                this.instancingData[instanceIndex].TextureIndex    = current.TextureIndex;
                this.instancingData[instanceIndex].AnimationOffset = animationOffset;

                instanceIndex++;
            }

            //Mark to write instancing data
            hasDataToWrite = instanceIndex > 0;
        }
示例#16
0
    public static DrawingData ReadDrawing(string fileName)
    {
        DrawingData drawFile = new DrawingData();
        TextAsset   file     = Resources.Load <TextAsset>(fileName);

        if (file == null)
        {
            Debug.LogError("Cound Not find File: " + fileName + " in the Resources Folder");
            return(drawFile);
        }

        drawFile = ParseDrawing(file.text);
        return(drawFile);
    }
示例#17
0
        private void draw(Graphics e, DrawingData a)
        {
            Pen p = new Pen(Color.Black, 2);

            using (Font useFont = new Font("Gotham Medium", 28, FontStyle.Bold))
            {
                RectangleF header2Rect = new RectangleF();
                int        moldX       = a.old.X - 5;
                int        moldY       = a.old.Y;
                header2Rect.Location = new Point(moldX, moldY);
                header2Rect.Size     = new Size(600, ((int)e.MeasureString(header2, useFont, 600, StringFormat.GenericTypographic).Height));
                e.DrawString(a.Rand, useFont, Brushes.Black, header2Rect);
            }
        }
示例#18
0
 public void Init(AstarPath active, DrawingData.Hasher hasher, DrawingData gizmos, RedrawScope redrawScope)
 {
     if (active != null)
     {
         debugData      = active.debugPathData;
         debugPathID    = active.debugPathID;
         debugMode      = active.debugMode;
         debugFloor     = active.debugFloor;
         debugRoof      = active.debugRoof;
         showSearchTree = active.showSearchTree && debugData != null;
     }
     this.hasher = hasher;
     builder     = gizmos.GetBuilder(hasher, redrawScope);
 }
示例#19
0
    public static DrawingData ParseDrawing(string file)
    {
        DrawingData drawFile = new DrawingData();

        string[] lines = file.Replace("\r\n", "\n")
                         .Replace("\r", "\n")
                         .Split(new string[] { "line\n" }, System.StringSplitOptions.RemoveEmptyEntries);
        //string[] lines = file.Split(new string[] { "line" }, System.StringSplitOptions.RemoveEmptyEntries);
        for (int i = 0; i < lines.Length; i++)
        {
            DrawingLine line = ReadDrawingLine(lines[i]);
            drawFile.Lines.Add(line);
        }
        return(drawFile);
    }
        public void UPDATEATTRIBUTES(Settings settings, DrawingData drawingData)
        {
            string attbName  = "";
            string attbValue = "";
            int    i         = 0;

            var AM = new AttributeManager();


            foreach (var attributeName in settings.PropertyNameList)
            {
                attbName  = attributeName;
                attbValue = drawingData.PropertyValueList[i];

                //Update TitleBlock
                if (i < settings.StartRevlinje && i >= settings.StartMerkeskilt)
                {
                    AM.UPDATEATTRIBUTESINDATABASE(
                        settings.TitleBlockName.ToUpper(),
                        attbName,
                        attbValue
                        );
                }

                //UpdateRevBlock
                if (i >= settings.StartRevlinje)
                {
                    //Avgjør revisjonsindex og plassering
                    int RevIndex = 1;
                    for (int x = 1; x < 7; x++)
                    {
                        if (AM.CHECKATTRIBUTEVALUE(settings.RevBlockName.ToUpper(), "REV" + x) == "" || AM.CHECKATTRIBUTEVALUE(settings.RevBlockName.ToUpper(), "REV" + x) == drawingData.PropertyValueList[settings.StartRevlinje])
                        {
                            RevIndex = x;
                            break;
                        }
                    }

                    AM.UPDATEATTRIBUTESINDATABASE(
                        settings.RevBlockName.ToUpper(),
                        attbName + RevIndex,
                        attbValue
                        );
                }

                i++;
            }
        }
示例#21
0
            /// <summary>
            /// Creates a new patch
            /// </summary>
            /// <param name="game">Game</param>
            /// <param name="content">Content</param>
            /// <param name="node">Quadtree node</param>
            /// <returns>Returns the new generated patch</returns>
            public static SceneryPatch CreatePatch(Game game, BufferManager bufferManager, ModelContent content, PickingQuadTreeNode <Triangle> node)
            {
                var desc = new DrawingDataDescription()
                {
                    Instanced      = false,
                    Instances      = 0,
                    LoadAnimation  = true,
                    LoadNormalMaps = true,
                    TextureCount   = 0,
                    DynamicBuffers = false,
                    Constraint     = node.BoundingBox,
                };

                var drawingData = DrawingData.Build(game, bufferManager, content, desc);

                return(new SceneryPatch(game, drawingData));
            }
示例#22
0
        public void OnDrawGizmos(DrawingData gizmos, RedrawScope redrawScope)
        {
            var hasher = new NodeHasher(AstarPath.active);

            hasher.Add(gizmoVersion);

            if (!gizmos.Draw(hasher, redrawScope))
            {
                using (var builder = gizmos.GetBuilder(hasher, redrawScope)) {
                    var centers = ArrayPool <Vector3> .Claim(areas.Length);

                    for (int i = 0; i < areas.Length; i++)
                    {
                        Int3 center = Int3.zero;
                        var  childs = children[i];
                        if (childs.Count > 0)
                        {
                            for (int j = 0; j < childs.Count; j++)
                            {
                                center += childs[j].position;
                            }
                            center    /= childs.Count;
                            centers[i] = (Vector3)center;
                        }
                    }

                    for (int i = 0; i < areas.Length; i++)
                    {
                        if (children[i].Count > 0)
                        {
                            for (int j = 0; j < connections[i].Count; j++)
                            {
                                if (connections[i][j] > i)
                                {
                                    builder.Line(centers[i], centers[connections[i][j]], Color.black);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#23
0
        /// <summary>
        /// Draws a mesh with a geometry drawer
        /// </summary>
        /// <param name="effect">Effect</param>
        /// <param name="drawingData">Drawing data</param>
        /// <param name="mode">Drawer mode</param>
        /// <param name="meshName">Mesh name</param>
        /// <param name="index">Instance buffer index</param>
        /// <param name="length">Instance buffer length</param>
        /// <returns>Returns the number of drawn triangles</returns>
        private int DrawMesh(IGeometryDrawer effect, DrawingData drawingData, DrawerModes mode, string meshName, int index, int length)
        {
            int count = 0;

            var graphics = this.Game.Graphics;

            var meshDict = drawingData.Meshes[meshName];

            foreach (string materialName in meshDict.Keys)
            {
                var mesh     = meshDict[materialName];
                var material = drawingData.Materials[materialName];

                bool transparent = material.Material.IsTransparent && this.Description.AlphaEnabled;
                if (mode.HasFlag(DrawerModes.OpaqueOnly) && transparent)
                {
                    continue;
                }
                if (mode.HasFlag(DrawerModes.TransparentOnly) && !transparent)
                {
                    continue;
                }

                count += mesh.IndexBuffer.Count > 0 ? mesh.IndexBuffer.Count / 3 : mesh.VertexBuffer.Count / 3;

                effect.UpdatePerObject(0, material, 0, this.UseAnisotropicFiltering);

                this.BufferManager.SetIndexBuffer(mesh.IndexBuffer.Slot);

                var technique = effect.GetTechnique(mesh.VertextType, true);
                this.BufferManager.SetInputAssembler(technique, mesh.VertexBuffer.Slot, mesh.Topology);

                for (int p = 0; p < technique.PassCount; p++)
                {
                    graphics.EffectPassApply(technique, p, 0);

                    mesh.Draw(graphics, index, length);
                }
            }

            return(count);
        }
示例#24
0
        void OnEnable()
        {
            if (_instance == null)
            {
                _instance = this;
            }

            // Ensure we don't have duplicate managers
            if (_instance != this)
            {
                // We cannot destroy the object while it is being enabled, so we need to delay it a bit
#if UNITY_EDITOR
                // This is only important in the editor to avoid a build-up of old managers.
                // In an actual game at most 1 (though in practice zero) old managers will be laying around.
                // It would be nice to use a coroutine for this instead, but unfortunately they do not work for objects marked with HideAndDontSave.
                EditorApplication.update += DelayedDestroy;
#endif
                return;
            }

            actuallyEnabled = true;
            if (gizmos == null)
            {
                gizmos = new DrawingData();
            }
            gizmos.frameRedrawScope = new RedrawScope(gizmos);
            Draw.builder            = gizmos.GetBuiltInBuilder(false);
            Draw.ingame_builder     = gizmos.GetBuiltInBuilder(true);
            commandBuffer           = new CommandBuffer();
            commandBuffer.name      = "ALINE Gizmos";

            // Callback when rendering with the built-in render pipeline
            Camera.onPostRender += PostRender;
            // Callback when rendering with a scriptable render pipeline
            UnityEngine.Rendering.RenderPipelineManager.beginFrameRendering += BeginFrameRendering;
            UnityEngine.Rendering.RenderPipelineManager.endCameraRendering  += EndCameraRendering;
#if UNITY_EDITOR
            EditorApplication.update += OnUpdate;
#endif
        }
示例#25
0
        protected void OnDrawItem(Object sender, DrawListViewItemEventArgs e)
        {
            e.DrawDefault = true;

            Int32        index  = e.ItemIndex;
            ListViewItem lvitem = e.Item;

            if (!IndexInItems(index))
            {
                return;
            }

            Object item = ItemsMap.TryGetValue(lvitem, (Object)lvitem);

            DrawingData data = ColorDictionary.TryGetValue(item, new DrawingData(DefaultBackgroundColor, DefaultForegroundColor, lvitem.Font));

            lvitem.ImageKey  = GetItemImageKey(lvitem);
            lvitem.BackColor = GetItemBackColor(lvitem, data);
            lvitem.ForeColor = GetItemForeColor(lvitem, data);
            lvitem.Font      = GetItemFont(lvitem, data);
            e.Graphics.FillRectangle(new SolidBrush(lvitem.BackColor), e.Item.Bounds);
        }
示例#26
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            F4SharedMem.FlightData curData = null;
            try { curData = _smReader.GetCurrentData(); } catch { }
            DrawingData drawingData = null;

            try { drawingData = curData != null ? curData.DrawingData : null; } catch { }

            StringData stringData = null;

            try { stringData = curData != null ? curData.StringData : null; } catch { }

            var stringDataData = stringData != null ? stringData.data : null;

            _HUDCommands = drawingData != null && !(string.IsNullOrWhiteSpace(drawingData.HUD_commands))
                                ? drawingData.HUD_commands
                                : "";

            _RWRCommands = drawingData != null && !(string.IsNullOrWhiteSpace(drawingData.RWR_commands))
                                ? drawingData.RWR_commands
                                : "";

            _HMSCommands = drawingData != null && !(string.IsNullOrWhiteSpace(drawingData.HMS_commands))
                                ? drawingData.HMS_commands
                                : "";

            var cockpitArtDir = stringDataData != null && stringDataData.Any(sd => sd.strId == (uint)StringIdentifier.ThrCockpitdir)
                                ? stringDataData.Where(sd => sd.strId == (uint)StringIdentifier.ThrCockpitdir).First().value
                                : "";

            _fontDir = string.IsNullOrWhiteSpace(cockpitArtDir) ? "" : Path.Combine(cockpitArtDir, "3DFont");

            Process(_HUDCommands, "HUD", txtHUD, lblHUDDataSize, pbHUD, ref _HUDImage);
            Draw(_HUDImage, _HUDCommands, pbHUD);
            Process(_RWRCommands, "RWR", txtRWR, lblRWRDataSize, pbRWR, ref _RWRImage);
            Draw(_RWRImage, _RWRCommands, pbRWR);
            Process(_HMSCommands, "HMS", txtHMS, lblHMSDataSize, pbHMS, ref _HMSImage);
            Draw(_HMSImage, _HMSCommands, pbHMS);
        }
示例#27
0
        public override ButtonController[] CreateButtons(int parentId)
        {
            GroupData         groupData         = groupsDataInitializer.Data.Groups[parentId];
            GroupProgressData groupProgressData = progressController.GetGroupData(parentId);

            int size = groupData.Drawings.Length;

            ButtonController[] result = new ButtonController[size];

            for (int i = 0; i < size; i++)
            {
                GameObject instance = CreateButton();

                DrawingData         drawingData         = groupData.Drawings[i];
                DrawingProgressData drawingProgressData = groupProgressData.Drawings[i];

                DrawingButtonController buttonController = instance.GetComponent <DrawingButtonController>();
                buttonController.Init(i, themeController.GetCurrentTheme(), drawingData, drawingProgressData);
                result[i] = buttonController;
            }

            return(result);
        }
        protected virtual void OnDrawItem(Object sender, DrawListViewItemEventArgs e)
        {
            e.DrawDefault = true;
            Int32 index = e.ItemIndex;

            if (!IndexInItems(index))
            {
                return;
            }

            if (e.Item is not GenericListViewItem <T> lvitem)
            {
                throw new CollectionSyncException();
            }

            DrawingData data = ColorDictionary.TryGetValue(lvitem.Item, new DrawingData(DefaultBackgroundColor, DefaultForegroundColor, lvitem.Font));

            lvitem.ImageKey  = GetItemImageKey(lvitem);
            lvitem.BackColor = GetItemBackColor(lvitem, data);
            lvitem.ForeColor = GetItemForeColor(lvitem, data);
            lvitem.Font      = GetItemFont(lvitem, data);
            e.Graphics.FillRectangle(new SolidBrush(lvitem.BackColor), e.Item.Bounds);
        }
示例#29
0
 public MainViewModel()
 {
     _drawingData = new DrawingData();
     _inkRenderer = new InkRenderer();
     Scale        = new ReactiveProperty <double>(1.0);
     CanvasWidth  = _drawingData.ObserveProperty(x => x.CanvasWidth)
                    .CombineLatest(Scale, (a, b) => a * b)
                    .ToReadOnlyReactiveProperty();
     CanvasHeight = _drawingData.ObserveProperty(x => x.CanvasHeight)
                    .CombineLatest(Scale, (a, b) => a * b)
                    .ToReadOnlyReactiveProperty();
     ViewportOffsetX      = _drawingData.ToReactivePropertyAsSynchronized(x => x.OffsetX, x => x * Scale.Value, x => x / Scale.Value);
     ViewportOffsetY      = _drawingData.ToReactivePropertyAsSynchronized(x => x.OffsetY, x => x * Scale.Value, x => x / Scale.Value);
     ViewportWidth        = _drawingData.ToReactivePropertyAsSynchronized(x => x.ViewWidth, x => x * Scale.Value, x => x / Scale.Value);
     ViewportHeight       = _drawingData.ToReactivePropertyAsSynchronized(x => x.ViewHeight, x => x * Scale.Value, x => x / Scale.Value);
     MinimapImage         = new ReactiveProperty <IRandomAccessStream>();
     MinimapViewportScale = _drawingData.ObserveProperty(x => x.CanvasWidth)
                            .CombineLatest(_drawingData.ObserveProperty(x => x.CanvasHeight), ValueTuple.Create)
                            .Select(((double width, double height)x) =>
     {
         var scaleW = 100 / x.width;
         var scaleH = 100 / x.height;
         return(Math.Min(scaleW, scaleH));
     }).ToReadOnlyReactiveProperty();
示例#30
0
        public void Init(int id, ThemeData themeData, DrawingData drawingData, DrawingProgressData progressData)
        {
            Init(id);

            background.color = themeData.GetColor(ThemeData.ColorEnum.BkgSecond);

            if (progressData.Completed)
            {
                mainImage.sprite = Resources.Load <Sprite>("Drawings/" + drawingData.Image);
            }
            else
            {
                questionMark.color = themeData.GetColor(ThemeData.ColorEnum.Second);
            }

            questionMark.enabled = !progressData.Completed;
            mainImage.enabled    = progressData.Completed;

            for (int i = 0; i < stars.Length; i++)
            {
                var star = stars[i];
                star.color = themeData.GetColor(i < progressData.Stars ? ThemeData.ColorEnum.Main : ThemeData.ColorEnum.Second);
            }
        }