Beispiel #1
0
    //from ActionTriggers.DisabledEverywhere through our message-only window
    internal static void OnDisableTriggers()
    {
        bool dis = ActionTriggers.DisabledEverywhere;

        EdTrayIcon.Disabled = dis;
        Strips.CheckCmd(nameof(CmdHandlers.Run_DisableTriggers), dis);
    }
Beispiel #2
0
    public FMain()
    {
        //#if DEBUG
        //		AOutput.QM2.UseQM2 = true; AOutput.Clear();
        //		SetHookToMonitorCreatedWindowsOfThisThread();
        //#endif

        Program.MainForm = this;

        this.SuspendLayout();
        this.AutoScaleMode = AutoScaleMode.None;
        this.Icon          = EdStock.IconAppNormal;
        this.StartPosition = FormStartPosition.Manual;
        unsafe {
            var s = Program.Settings.wndPos;
            if (s != null && Au.Util.AConvert.Base64UrlDecode(s, out Api.WINDOWPLACEMENT p))
            {
                p.rcNormalPosition.EnsureInScreen();
                this.Bounds = p.rcNormalPosition;
                if (p.showCmd == Api.SW_SHOWMAXIMIZED)
                {
                    this.WindowState = FormWindowState.Maximized;
                }
            }
            else
            {
                var wa = AScreen.Primary.WorkArea;
                this.Bounds = new Rectangle(wa.left + 10, wa.top + 10, wa.Width * 3 / 4, wa.Height - 20);
            }
        }

        //APerf.Next();
        Strips.Init();
        MainMenuStrip = Strips.Menubar;
        //APerf.Next();
        Panels.Init();

        this.Controls.Add(Panels.PanelManager);

        this.ResumeLayout(false);

        this.Hwnd(create: true);         //this does not create child control handles. We need only of the main form.

        Program.Tasks = new RunningTasks();
        Panels.Files.ZLoadWorkspace(CommandLine.WorkspaceDirectory);
        EdTrayIcon.Add();
        CommandLine.OnProgramLoaded();
        Program.Loaded = EProgramState.LoadedWorkspace;
        Program.Model.RunStartupScripts();

        //APerf.Next();

        //#if DEBUG
        //		ADebug.Print("Ending form ctor. Must be no parked controls created; use SetHookToMonitorCreatedWindowsOfThisThread.");
        //#endif

#if TRACE
        _MonitorGC();
#endif
    }
Beispiel #3
0
        public void MergeStrips()
        {
            bool        bFirst         = true;
            int         previousStrip  = 0;
            List <int>  mergedStrip    = new List <int>();
            List <bool> removeOldStrip = new List <bool>();

            for (int k = 0; k < Strips.Count; k++)
            {
                if (Strips[k].Count == 3)
                {
                    // We don't want to add single triangles into our tristrips
                    removeOldStrip.Add(false);
                    continue;
                }

                if (!bFirst)
                {
                    int lastRef  = Strips[previousStrip][Strips[previousStrip].Count - 1];
                    int firstRef = Strips[k][0];

                    mergedStrip.Add(lastRef);
                    mergedStrip.Add(firstRef);

                    if (OneSided)
                    {
                        if ((mergedStrip.Count & 1) == 1)
                        {
                            int secondRef = Strips[k][1];

                            if (firstRef != secondRef)
                            {
                                mergedStrip.Add(firstRef);
                            }
                            else
                            {
                                Strips[k].RemoveAt(0);
                            }
                        }
                    }
                }

                mergedStrip.AddRange(Strips[k]);

                bFirst        = false;
                previousStrip = k;
                removeOldStrip.Add(true);
            }

            for (int i = Strips.Count - 1; i >= 0; i--)
            {
                if (removeOldStrip[i])
                {
                    Strips.RemoveAt(i);
                }
            }

            Strips.Insert(0, mergedStrip);
        }
Beispiel #4
0
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.Add(FacesName, Faces.ExportYAML(container));
            node.Add(StripsName, Strips.ExportYAML(true));
            return(node);
        }
Beispiel #5
0
 /// <summary>
 /// Clears all vertices, indices, bone tables, materials and strips.
 /// </summary>
 public void Clear()
 {
     BoneTable.Clear();
     Vertices.Clear();
     Indices.Clear();
     Materials.Clear();
     Strips.Clear();
 }
Beispiel #6
0
 /// <summary>
 /// Adds a strip to the collection
 /// </summary>
 /// <param name="strip"></param>
 public void AddStrip(Strip strip)
 {
     strip.StripItems       = GetListofStripItems(DefaultStripColor);
     strip.ColorValues      = new ObservableCollection <string>(stripColors);
     strip.viewmodel        = this;
     strip.PropertyChanged += Strip_PropertyChanged;
     Strips.Add(strip);
 }
Beispiel #7
0
        public MeshData Convert()
        {
            MeshData instance = new MeshData();

            instance.Faces  = Faces.ToArray();
            instance.Strips = Strips.ToArray();
            return(instance);
        }
Beispiel #8
0
        /// <summary>
        /// Sets the properties of a new strip then adds it to the collection
        /// </summary>
        public void AddStrip()
        {
            var strip = new Strip(RoomNumber, DefaultStripColor)
            {
                StripItems  = GetListofStripItems(DefaultStripColor),
                ColorValues = new ObservableCollection <string>(stripColors),
                viewmodel   = this,
            };

            strip.PropertyChanged += Strip_PropertyChanged;
            Strips.Add(strip);
        }
Beispiel #9
0
 /// <summary>
 /// Removes a strip from the collection
 /// </summary>
 /// <param name="Strip">
 /// The strip to remove from the collection
 /// </param>
 public void Remove(Strip Strip)
 {
     if (Strip != null)
     {
         // Remove the price before you remove the strip, otherwise the price will stay the same
         TotalPrice -= Strip.Price;
         if (Strips.Contains(Strip))
         {
             Strips.Remove(Strip);
         }
     }
     else
     {
         MessageBox.Show("You must select an item before removing it.");
     }
 }
Beispiel #10
0
        public override void SetAndRefreshData(Structures.BlockBase blockBase)
        {
            base.SetAndRefreshData(blockBase);

            _zPlane = (ZPlane)blockBase;

            StripCount.Text = "Number of Strips: " + _zPlane.Strips.Count;

            Strips.Items.Clear();
            foreach (ZPlaneStripData zPlaneStripData in _zPlane.Strips)
            {
                ListViewItem item = Strips.Items.Add(zPlaneStripData.OffSet.ToString());
                item.SubItems.Add(zPlaneStripData.ImageData.Length.ToString());
            }

            Strips.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Beispiel #11
0
        public async Task LoadAsync()
        {
            Strips.Clear();
            Rants.Clear();

            FeedParser   feedParser = new();
            IList <Item> items      = feedParser.ParseRss(new Uri("https://megatokyo.com/rss/megatokyo.xml"));

            CheckingDomain checking = await _mediator.Send(new GetCheckingQuery(1));

            if (checking == null)
            {
                checking = new(DateTimeOffset.MinValue, 0, 0);
                await _mediator.Send(new CreateCheckingCommand(checking));
            }

#if DEBUG
            DateTimeOffset lastCheck = DateTime.Now.AddDays(-30);
#else
            DateTimeOffset lastCheck = checking.LastCheck;
#endif
            LastStripNumber = checking.LastStripNumber;
            LastRantNumber  = checking.LastRantNumber;

            foreach (Item item in items)
            {
                if (item.PublishDate > lastCheck)
                {
                    if (item.Title.StartsWith("Comic", StringComparison.InvariantCulture))
                    {
                        StringExtractor stringExtractor = new(item.Title);
                        StripDomain     strip           = new(int.Parse(stringExtractor.Extract("[", "]", false), NumberStyles.Integer, CultureInfo.InvariantCulture));
                        Strips.Add(strip);
                        checking.LastStripNumber = strip.Number;
                    }
                    if (item.Title.StartsWith("Rant", StringComparison.InvariantCulture))
                    {
                        StringExtractor stringExtractor = new(item.Title);
                        RantDomain      rant            = new(int.Parse(stringExtractor.Extract("[", "]", false), NumberStyles.Integer, CultureInfo.InvariantCulture));
                        Rants.Add(rant);
                        checking.LastRantNumber = rant.Number;
                    }
                }
            }
            await _mediator.Send(new UpdateCheckingCommand(checking));
        }
Beispiel #12
0
    public void ZUpdateList()
    {
        //ADebug.PrintFunc();
        bool cmdPrevDisable = (Program.Model?.OpenFiles.Count ?? 0) < 2;

        if (cmdPrevDisable != _cmdPrevDisabled)
        {
            _cmdPrevDisabled = cmdPrevDisable;
            Strips.EnableCmd(nameof(CmdHandlers.File_PreviousDocument), !cmdPrevDisable);
        }
        if (_c.Model == null)
        {
            _c.Model = this;
        }
        else
        {
            StructureChanged?.Invoke(this, new TreePathEventArgs(TreePath.Empty));
        }
    }
        public override void SetAndRefreshData(Structures.BlockBase blockBase)
        {
            base.SetAndRefreshData(blockBase);

            _stripTable = (ImageStripTable)blockBase;

            StripCount.Text = "Number of Strips: " + _stripTable.Strips.Count;

            Strips.Items.Clear();
            foreach (StripData colorCycle in _stripTable.Strips)
            {
                ListViewItem item = Strips.Items.Add(colorCycle.OffSet.ToString());
                item.SubItems.Add(string.Format("{0} (0x{1})", colorCycle.CodecId, colorCycle.CodecId.ToString("X").PadLeft(2, '0')));
                item.SubItems.Add(colorCycle.ImageData.Length.ToString());
                item.SubItems.Add(Enum.GetName(typeof(CompressionTypes), colorCycle.CompressionType));
                item.SubItems.Add(Enum.GetName(typeof(RenderingDirections), colorCycle.RenderdingDirection));
                item.SubItems.Add(colorCycle.Transparent.ToString());
                item.SubItems.Add(string.Format("{0} (0x{1})", colorCycle.ParamSubtraction, colorCycle.ParamSubtraction.ToString("X").PadLeft(2, '0')));
            }

            Strips.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Beispiel #14
0
        public int ComputeBestStrip(int face)
        {
            List <int>[] strip  = new List <int> [3];
            List <int>[] faces  = new List <int> [3];
            int[]        length = new int[3];

            int[] firstLength = new int[3];
            int[] refs0       = new int[3];
            int[] refs1       = new int[3];
            refs0[0] = adjacency.Faces[face].Ref[0];
            refs1[0] = adjacency.Faces[face].Ref[1];

            refs0[1] = adjacency.Faces[face].Ref[2];
            refs1[1] = adjacency.Faces[face].Ref[0];

            refs0[2] = adjacency.Faces[face].Ref[1];
            refs1[2] = adjacency.Faces[face].Ref[2];

            for (int j = 0; j < 3; j++)
            {
                strip[j] = new List <int>();
                faces[j] = new List <int>();

                bool[] ltags = new bool[tags.Length];
                Array.Copy(tags, ltags, tags.Length);

                length[j]      = TrackStrip(face, refs0[j], refs1[j], ref strip[j], ref faces[j], ltags);
                firstLength[j] = length[j];

                for (int i = 0; i < length[j] / 2; i++)
                {
                    int t = strip[j][i];
                    strip[j][i] = strip[j][length[j] - i - 1];
                    strip[j][length[j] - i - 1] = t;
                }

                for (int i = 0; i < (length[j] - 2) / 2; i++)
                {
                    int t = faces[j][i];
                    faces[j][i] = faces[j][length[j] - i - 3];
                    faces[j][length[j] - i - 3] = t;
                }

                int newRef0     = strip[j][length[j] - 3];
                int newRef1     = strip[j][length[j] - 2];
                int extraLength = TrackStrip(face, newRef0, newRef1, ref strip[j], ref faces[j], ltags, length[j] - 3);
                length[j] += extraLength - 3;
            }

            int bestLength = length[0];
            int best       = 0;

            if (bestLength < length[1])
            {
                bestLength = length[1]; best = 1;
            }
            if (bestLength < length[2])
            {
                bestLength = length[2]; best = 2;
            }

            int nFaces = bestLength - 2;

            for (int j = 0; j < bestLength - 2; j++)
            {
                tags[faces[best][j]] = true;
            }

            if (OneSided && (firstLength[best] & 1) == 1)
            {
                if (bestLength == 3 || bestLength == 4)
                {
                    strip[best][1] ^= strip[best][2];
                    strip[best][2] ^= strip[best][1];
                    strip[best][1] ^= strip[best][2];
                }
                else
                {
                    for (int i = 0; i < bestLength / 2; i++)
                    {
                        int t = strip[best][i];
                        strip[best][i] = strip[best][bestLength - i - 1];
                        strip[best][length[best] - i - 1] = t;
                    }

                    if (((bestLength - firstLength[best]) & 1) == 1)
                    {
                        strip[best].Insert(0, strip[best][0]);
                    }
                }
            }

            Strips.Add(new List <int>(strip[best]));

            return(nFaces);
        }
Beispiel #15
0
 public void Write(AssetWriter writer)
 {
     Faces.Write(writer);
     Strips.Write(writer);
 }
Beispiel #16
0
        /// <summary>
        /// Saves the file to the specified stream.
        /// </summary>
        /// <param name="stream">The stream to save to.</param>
        public override void Save(Stream stream)
        {
            BinaryWriter writer = new BinaryWriter(stream, Encoding.GetEncoding("EUC-KR"));

            writer.WriteString(FILE_IDENTIFIER_8);
            writer.Write((byte)0);

            writer.Write((int)format);

            writer.Write(BoundingBox.Minimum);
            writer.Write(BoundingBox.Maximum);

            writer.Write((short)BoneTable.Count);

            BoneTable.ForEach(bone => {
                writer.Write(bone);
            });

            writer.Write((short)Vertices.Count);

            Vertices.ForEach(vertex => {
                writer.Write(vertex.Position);
            });

            if (NormalsEnabled)
            {
                Vertices.ForEach(vertex => {
                    writer.Write(vertex.Normal);
                });
            }

            if (ColoursEnabled)
            {
                Vertices.ForEach(vertex => {
                    writer.Write(vertex.Colour.Alpha);
                    writer.Write(vertex.Colour.Red);
                    writer.Write(vertex.Colour.Green);
                    writer.Write(vertex.Colour.Blue);
                });
            }

            if (BonesEnabled)
            {
                Vertices.ForEach(vertex => {
                    writer.Write(vertex.BoneWeights);
                    writer.Write(vertex.BoneIndices);
                });
            }

            if (TangentsEnabled)
            {
                Vertices.ForEach(vertex => {
                    writer.Write(vertex.Tangent);
                });
            }

            if (TextureCoordinates1Enabled)
            {
                Vertices.ForEach(vertex => {
                    writer.Write(vertex.TextureCoordinates[0]);
                });
            }

            if (TextureCoordinates2Enabled)
            {
                Vertices.ForEach(vertex => {
                    writer.Write(vertex.TextureCoordinates[1]);
                });
            }

            if (TextureCoordinates3Enabled)
            {
                Vertices.ForEach(vertex => {
                    writer.Write(vertex.TextureCoordinates[2]);
                });
            }

            if (TextureCoordinates4Enabled)
            {
                Vertices.ForEach(vertex => {
                    writer.Write(vertex.TextureCoordinates[3]);
                });
            }

            writer.Write((short)Indices.Count);

            Indices.ForEach(index => {
                writer.Write(index);
            });

            writer.Write((short)Materials.Count);

            Materials.ForEach(material => {
                writer.Write(material);
            });

            writer.Write((short)Strips.Count);

            Strips.ForEach(strip => {
                writer.Write(strip);
            });

            writer.Write((short)Pool);
        }
Beispiel #17
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("EUC-KR"));

            string identifier = reader.ReadNullTerminatedString();

            int version;

            if (string.Compare(identifier, FILE_IDENTIFIER_7, false) == 0)
            {
                version = 7;
            }
            else if (string.Compare(identifier, FILE_IDENTIFIER_8, false) == 0)
            {
                version = 8;
            }
            else
            {
                throw new FileIdentifierMismatchException(FilePath, string.Format("{0} / {1}", FILE_IDENTIFIER_7, FILE_IDENTIFIER_8), identifier);
            }

            format      = (VertexFormat)reader.ReadInt32();
            BoundingBox = new BoundingBox(reader.ReadVector3(), reader.ReadVector3());

            short boneCount = reader.ReadInt16();

            for (int i = 0; i < boneCount; i++)
            {
                BoneTable.Add(reader.ReadInt16());
            }

            short vertexCount = reader.ReadInt16();

            for (int i = 0; i < vertexCount; i++)
            {
                ModelVertex vertex = new ModelVertex();
                vertex.Position = reader.ReadVector3();

                Vertices.Add(vertex);
            }

            if (NormalsEnabled)
            {
                for (int i = 0; i < vertexCount; i++)
                {
                    ModelVertex vertex = Vertices[i];
                    vertex.Normal = reader.ReadVector3();
                }
            }

            if (ColoursEnabled)
            {
                for (int i = 0; i < vertexCount; i++)
                {
                    float alpha = reader.ReadSingle();

                    ModelVertex vertex = Vertices[i];
                    vertex.Colour = new Color4(reader.ReadVector3(), alpha);
                }
            }

            if (BonesEnabled)
            {
                for (int i = 0; i < vertexCount; i++)
                {
                    ModelVertex vertex = Vertices[i];
                    vertex.BoneWeights = reader.ReadVector4();
                    vertex.BoneIndices = reader.ReadShortVector4();
                }
            }

            if (TangentsEnabled)
            {
                for (int i = 0; i < vertexCount; i++)
                {
                    ModelVertex vertex = Vertices[i];
                    vertex.Tangent = reader.ReadVector3();
                }
            }

            if (TextureCoordinates1Enabled)
            {
                for (int i = 0; i < vertexCount; i++)
                {
                    ModelVertex vertex = Vertices[i];
                    vertex.TextureCoordinates[0] = reader.ReadVector2();
                }
            }

            if (TextureCoordinates2Enabled)
            {
                for (int i = 0; i < vertexCount; i++)
                {
                    ModelVertex vertex = Vertices[i];
                    vertex.TextureCoordinates[1] = reader.ReadVector2();
                }
            }

            if (TextureCoordinates3Enabled)
            {
                for (int i = 0; i < vertexCount; i++)
                {
                    ModelVertex vertex = Vertices[i];
                    vertex.TextureCoordinates[2] = reader.ReadVector2();
                }
            }

            if (TextureCoordinates4Enabled)
            {
                for (int i = 0; i < vertexCount; i++)
                {
                    ModelVertex vertex = Vertices[i];
                    vertex.TextureCoordinates[3] = reader.ReadVector2();
                }
            }

            short indexCount = reader.ReadInt16();

            for (int i = 0; i < indexCount; i++)
            {
                Indices.Add(reader.ReadShortVector3());
            }

            short materialCount = reader.ReadInt16();

            for (int i = 0; i < materialCount; i++)
            {
                Materials.Add(reader.ReadInt16());
            }

            short stripCount = reader.ReadInt16();

            for (int i = 0; i < stripCount; i++)
            {
                Strips.Add(reader.ReadInt16());
            }

            if (version >= 8)
            {
                Pool = (PoolType)reader.ReadInt16();
            }
        }