Esempio n. 1
0
        bool allowReplace()
        {
            if (!criteriaEnabled)
            {
                return(false);
            }

            Criteria c = FromCriteria;

            if (c.ResourceType == null && c.ResourceGroup == null && c.Instance == null)
            {
                return(false);
            }
            c = ToCriteria;
            if (c.ResourceType == null && c.ResourceGroup == null && c.Instance == null)
            {
                return(false);
            }

            AResourceKey from = new RK(FromCriteria.ResourceKey);
            AResourceKey to   = new RK(ToCriteria.GetValueOrDefault(from));
            bool         res  = to.Equals(from);

            return(!res);
        }
Esempio n. 2
0
        public static bool ParseRK(string value, out RK result)
        {
            result = null;
            string[] entries = value.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
            if (entries.Length < 3)
            {
                return(false);
            }
            uint  tid, gid;
            ulong iid;

            if (!uint.TryParse(entries[0], NumberStyles.HexNumber, null, out tid))
            {
                return(false);
            }
            if (!uint.TryParse(entries[1], NumberStyles.HexNumber, null, out gid))
            {
                return(false);
            }
            if (!ulong.TryParse(entries[2], NumberStyles.HexNumber, null, out iid))
            {
                return(false);
            }
            result = new RK(RK.NULL);
            result.ResourceType  = tid;
            result.ResourceGroup = gid;
            result.Instance      = iid;
            return(true);
        }
Esempio n. 3
0
 public CreatePropNode()
     : base(ResourceType, ResourceTag)
 {
     this.mPropActor = null;
     this.mPropParam = null;
     this.mPropKey = new RK();
 }
Esempio n. 4
0
        public JazzGraphContainer(int index,
                                  StateMachine sm, Control view, TabPage page)
        {
            this.Index     = index;
            this.mName     = sm.Name;
            this.UndoRedo  = new UndoManager();
            this.SaveState = JazzSaveState.Dirty;
            this.Key       = new RK(GlobalManager.kJazzTID, 0,
                                    FNVHash.HashString64(this.mName));
            this.Comp = true;
            this.JP   = null;
            this.RIE  = null;

            this.Scene = new StateMachineScene(sm, view, this);
            KKLayoutAlgorithm <StateNode, StateEdge> layout
                = new KKLayoutAlgorithm <StateNode, StateEdge>(
                      this.Scene.StateGraph, this.Scene);

            layout.LengthFactor = 1.25f;
            this.Scene.Layout   = layout;
            layout.ShuffleNodes();
            this.Scene.LayoutPaused = true;
            this.Scene.StartLayout();

            this.mPage = page;
            this.mPage.Controls.Add(view);
            this.mPage.Text         = this.mName + " *";
            this.mPage.SizeChanged +=
                new EventHandler(this.OnTabSizeChanged);
        }
Esempio n. 5
0
 public CreatePropNode()
     : base(ResourceType, ResourceTag)
 {
     this.mPropActor = null;
     this.mPropParam = null;
     this.mPropKey   = new RK();
 }
Esempio n. 6
0
            public GraphNode(ResourceGraph graph, IResourceKey originalKey, IResourceNode core,
                             PathPackageTuple origin, ResourceDataActions nodeActions, RFileType fileType = RFileType.Unknown)
            {
                this.Graph        = graph;
                this.key          = new RK(originalKey);
                this.OriginalKey  = new RK(originalKey);
                this.ExtensionTag = s3pi.Extensions.ExtList.Ext[originalKey.ResourceType][0];
                this.NodeActions  = nodeActions;
                this.Core         = core;
                this.Origin       = origin;
                if (fileType == RFileType.Unknown)
                {
                    this.fileType = ResourceGraph.GetFileType(originalKey.ResourceType);
                }
                else
                {
                    this.fileType = fileType;
                }
                switch (this.fileType)
                {
                case RFileType.Game:
                    this.name = NameMap.GameNMap.GetName(originalKey.Instance, origin);
                    break;

                case RFileType.DDS:
                    this.name = NameMap.DDSNMap.GetName(originalKey.Instance, origin);
                    break;

                case RFileType.Thum:
                    this.name = NameMap.ThumNMap.GetName(originalKey.Instance, origin);
                    break;
                }
                this.originalName = this.name;
            }
Esempio n. 7
0
        public JazzGraphContainer(int index, string name, Control view)
        {
            this.Index     = index;
            this.mName     = name ?? "";
            this.UndoRedo  = new UndoManager();
            this.SaveState = JazzSaveState.Dirty;
            ulong iid = 0;

            if (!this.mName.StartsWith("0x") ||
                !ulong.TryParse(this.mName.Substring(2),
                                System.Globalization.NumberStyles.HexNumber,
                                null, out iid))
            {
                iid = FNVHash.HashString64(this.mName);
            }
            this.Key  = new RK(GlobalManager.kJazzTID, 0, iid);
            this.Comp = true;
            this.JP   = null;
            this.RIE  = null;

            StateMachine sm = new StateMachine(name);

            this.Scene = new StateMachineScene(sm, view, this);
            KKLayoutAlgorithm <StateNode, StateEdge> layout
                = new KKLayoutAlgorithm <StateNode, StateEdge>(
                      this.Scene.StateGraph, this.Scene);

            layout.LengthFactor = 1.25f;
            this.Scene.Layout   = layout;
            layout.ShuffleNodes();
            this.Scene.LayoutPaused = true;
            this.Scene.StartLayout();
        }
Esempio n. 8
0
        private void rtgiPasteRK_Click(object sender, EventArgs e)
        {
            IResourceKey rk;

            if (RK.TryParse(Clipboard.GetText(), out rk))
            {
                ToolStripDropDownItem tsmi = sender as ToolStripDropDownItem;
                if (tsmi == null || tsmi.Owner as ContextMenuStrip == null)
                {
                    return;
                }
                if ((tsmi.Owner as ContextMenuStrip).SourceControl == tlpFromTGIValues)
                {
                    cbFromResourceType.Value = rk.ResourceType;
                    tbFromResourceGroup.Text = "0x" + rk.ResourceGroup.ToString("X8");
                    tbFromInstance.Text      = "0x" + rk.Instance.ToString("X16");
                }
                else
                {
                    cbToResourceType.Value = rk.ResourceType;
                    tbToResourceGroup.Text = "0x" + rk.ResourceGroup.ToString("X8");
                    tbToInstance.Text      = "0x" + rk.Instance.ToString("X16");
                }
            }
        }
Esempio n. 9
0
    public static void SetValue(String Name, object Value)
    {
        RegistryKey RK;

        RK = Registry.CurrentUser.OpenSubKey(AppMain.AppName, true);
        RK.SetValue(Name, Value);
        RK.Close();
    }
Esempio n. 10
0
    public static void DeleteValue(String Name)
    {
        RegistryKey RK;

        RK = Registry.CurrentUser.OpenSubKey(AppMain.AppName, true);
        RK.DeleteValue(Name, false);
        RK.Close();
    }
Esempio n. 11
0
        public JazzGraphContainer(int index, JazzPackage jp,
                                  IResourceIndexEntry rie, Control view, TabPage page)
        {
            this.Index     = index;
            this.UndoRedo  = new UndoManager();
            this.SaveState = JazzSaveState.Saved;
            this.Key       = new RK(rie);
            this.Comp      = rie.Compressed == 0xFFFF;
            this.JP        = jp;
            this.RIE       = rie;
            IResource           res  = null;
            GenericRCOLResource rcol = null;

            try
            {
                res = WrapperDealer.GetResource(0, jp.Package, rie);
            }
            catch (Exception ex)
            {
                MainForm.ShowException(ex,
                                       "Could not load JAZZ resource: " + this.Key + "\n",
                                       MainForm.kName + ": Unable to load JAZZ resource");
            }
            if (res != null)
            {
                rcol = res as GenericRCOLResource;
                if (rcol != null)
                {
                    this.Scene = new StateMachineScene(
                        new StateMachine(rcol), view, this);
                    KKLayoutAlgorithm <StateNode, StateEdge> layout
                        = new KKLayoutAlgorithm <StateNode, StateEdge>(
                              this.Scene.StateGraph, this.Scene);
                    layout.LengthFactor = 1.25f;
                    this.Scene.Layout   = layout;
                    layout.ShuffleNodes();
                    this.Scene.LayoutPaused = true;
                    this.Scene.StartLayout();
                }
                else
                {
                    this.Scene = null;
                }
            }
            if (!KeyNameReg.TryFindName(rie.Instance, out this.mName))
            {
                this.mName = "0x" + rie.Instance.ToString("X16");
            }
            if (this.Scene != null)
            {
                this.mPage = page;
                this.mPage.Controls.Add(view);
                this.mPage.Text         = this.mName;
                this.mPage.SizeChanged +=
                    new EventHandler(this.OnTabSizeChanged);
            }
        }
Esempio n. 12
0
 public JazzGraphNamePrompt()
 {
     this.mKey    = new RK(GlobalManager.kJazzTID, 0, 0);
     this.mName   = "";
     this.mPrompt = new SingleStringPrompt(
         kPromptText + this.mKey, "Jazz Graph Name", "");
     this.mOnTextChanged
         = new EventHandler(this.OnResponseTextChanged);
     this.mPrompt.ResponseTextChanged += this.mOnTextChanged;
 }
Esempio n. 13
0
 public PlayAnimationNode()
     : base(ResourceType, ResourceTag)
 {
     this.mClipKey             = new RK();
     this.mTrackMaskKey        = new RK();
     this.mSlotSetup           = new SlotSetupBuilder();
     this.mAdditiveClipKey     = new RK();
     this.mClipPattern         = null;
     this.mAdditiveClipPattern = null;
 }
Esempio n. 14
0
 public PlayAnimationNode()
     : base(ResourceType, ResourceTag)
 {
     this.mClipKey = new RK();
     this.mTrackMaskKey = new RK();
     this.mSlotSetup = new SlotSetupBuilder();
     this.mAdditiveClipKey = new RK();
     this.mClipPattern = null;
     this.mAdditiveClipPattern = null;
 }
Esempio n. 15
0
    public static String [] GetNames()
    {
        RegistryKey RK;

        RK = Registry.CurrentUser.OpenSubKey(AppMain.AppName);
        String [] Names = RK.GetValueNames();
        RK.Close();

        return(Names);
    }
 public JazzGraphNamePrompt()
 {
     this.mKey = new RK(GlobalManager.kJazzTID, 0, 0);
     this.mName = "";
     this.mPrompt = new SingleStringPrompt(
         kPromptText + this.mKey, "Jazz Graph Name", "");
     this.mOnTextChanged
         = new EventHandler(this.OnResponseTextChanged);
     this.mPrompt.ResponseTextChanged += this.mOnTextChanged;
 }
Esempio n. 17
0
        private void tgisPasteRK_Click(object sender, EventArgs e)
        {
            IResourceKey rk;

            if (RK.TryParse(Clipboard.GetText(), out rk))
            {
                cbResourceType.Value = rk.ResourceType;
                tbResourceGroup.Text = "0x" + rk.ResourceGroup.ToString("X8");
                tbInstance.Text      = "0x" + rk.Instance.ToString("X16");
            }
        }
Esempio n. 18
0
    public static object GetValue(String Name)
    {
        RegistryKey RK;

        RK = Registry.CurrentUser.OpenSubKey(AppMain.AppName, true);
        object Value = RK.GetValue(Name);

        RK.Close();

        return(Value);
    }
Esempio n. 19
0
        /// <summary>
        /// Adds a RK Biffrecord to the internal list
        /// additional the method adds the specific RK Data to a data container
        /// </summary>
        /// <param name="number">NUMBER Biffrecord</param>
        public void addRK(RK singlerk)
        {
            this.SINGLERKList.Add(singlerk);
            RowData    rowData = this.getSpecificRow(singlerk.rw);
            NumberCell cell    = new NumberCell();

            cell.setValue(singlerk.num);
            cell.Col        = singlerk.col;
            cell.Row        = singlerk.rw;
            cell.TemplateID = singlerk.ixfe;
            rowData.addCell(cell);
        }
Esempio n. 20
0
  { public static void CreateAccount()
    {
        RegistryKey RK;

        RK = Registry.CurrentUser.OpenSubKey(AppMain.AppName, true);

        if (RK == null)
        {
            RK = Registry.CurrentUser.CreateSubKey(AppMain.AppName);
        }

        RK.Close();
    }
Esempio n. 21
0
        /// <summary>
        /// Returns the value or values defined by the Registry Value query nominated by ID. The list of known IDs is
        /// stored in Program.Settings so it can be saved and restored
        /// </summary>
        /// <param name="ID">The named identifier for the Registry value to be queried</param>
        /// <returns>Array of strings (1+)</returns>
        private string[] ReadRegistry(string ID)
        {
            // Find the query information
            Ventajou.WPInfo.RegValue R = Program.Settings.RegValues.Find(RegValue => RegValue.Name == ID);
            try
            {
                RegistryKey RK;
                switch (R.Key)
                {
                case RegValue.HKLM: RK = Registry.LocalMachine; break;

                case RegValue.HKCU: RK = Registry.CurrentUser; break;

                case RegValue.HKCC: RK = Registry.CurrentConfig; break;

                case RegValue.HKCR: RK = Registry.ClassesRoot; break;

                case RegValue.HKU: RK = Registry.Users; break;

                default: RK = Registry.LocalMachine; break;
                }
                RegistryKey SK = RK.OpenSubKey(R.Path, false);
                if (SK == null)
                {
                    throw new Exception("Could not find Path in Hive");
                }
                RegistryValueKind RVK = SK.GetValueKind(R.Value);
                // Format the value based on its type
                switch (RVK)
                {
                case RegistryValueKind.MultiString:
                    return(new string[] { SK.GetValue(R.Value).ToString() });

                case RegistryValueKind.Binary:
                    byte[]        bytes = (byte[])SK.GetValue(R.Value);
                    StringBuilder sb    = new StringBuilder();
                    for (int i = 0; i < bytes.Length; i++)
                    {
                        sb.AppendFormat(" {0:X2}", bytes[i]);
                    }
                    return(new string[] { sb.ToString() });

                default:
                    return(new string[] { String.Format("{0}", SK.GetValue(R.Value)) });
                }
            }
            catch (Exception e)
            {
                return(new string[] { "Registry value " + R.Name + " error: " + e.Message });
            }
        }
Esempio n. 22
0
 public bool IsKindred(IResourceIndexEntry rie)
 {
     if (this.KinHelper.IsKindred(this.ParentKey, rie))
     {
         RK rk = new RK(rie);
         for (int i = 0; i < this.Seen.Count; i++)
         {
             if (rk.Equals(this.Seen[i]))
             {
                 return(false);
             }
         }
         return(true);
     }
     return(false);
 }
Esempio n. 23
0
    public static bool HasKey(String Name)
    {
        RegistryKey RK;

        RK = Registry.CurrentUser.OpenSubKey(AppMain.AppName, true);
        object Value = RK.GetValue(Name);

        RK.Close();

        if (Value == null)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Esempio n. 24
0
 public void ResetKey()
 {
     if (!this.key.Equals(this.OriginalKey))
     {
         string log = "Resetting " + PrintRKTag(this.key, this.ExtensionTag)
                      + " back to " + PrintRK(this.OriginalKey);
         Diagnostics.Log("Started " + log);
         RK rk = new RK(this.OriginalKey);
         //this.OriginalKey.ResourceType = this.key.ResourceType;
         //this.OriginalKey.ResourceGroup = this.key.ResourceGroup;
         this.OriginalKey.Instance = this.key.Instance;
         this.Key = rk;
         //this.OriginalKey.ResourceType = this.key.ResourceType;
         //this.OriginalKey.ResourceGroup = this.key.ResourceGroup;
         this.OriginalKey.Instance = this.key.Instance;
         Diagnostics.Log("Finished " + log);
     }
 }
 public JazzGraphNamePrompt(string name, string bannedName)
 {
     this.mName = name ?? "";
     this.mKey = new RK(GlobalManager.kJazzTID, 0, 0);
     this.ParseIID();
     this.mPrompt = new SingleStringPrompt(
         kPromptText + this.mKey, "Jazz Graph Name", this.mName);
     if (!string.IsNullOrEmpty(bannedName))
     {
         this.BannedNames.Add(bannedName);
         if (this.mName.Equals(bannedName))
         {
             this.mPrompt.OKEnabled = false;
         }
     }
     this.mOnTextChanged
         = new EventHandler(this.OnResponseTextChanged);
     this.mPrompt.ResponseTextChanged += this.mOnTextChanged;
 }
Esempio n. 26
0
 public JazzGraphNamePrompt(string name, string bannedName)
 {
     this.mName = name ?? "";
     this.mKey  = new RK(GlobalManager.kJazzTID, 0, 0);
     this.ParseIID();
     this.mPrompt = new SingleStringPrompt(
         kPromptText + this.mKey, "Jazz Graph Name", this.mName);
     if (!string.IsNullOrEmpty(bannedName))
     {
         this.BannedNames.Add(bannedName);
         if (this.mName.Equals(bannedName))
         {
             this.mPrompt.OKEnabled = false;
         }
     }
     this.mOnTextChanged
         = new EventHandler(this.OnResponseTextChanged);
     this.mPrompt.ResponseTextChanged += this.mOnTextChanged;
 }
Esempio n. 27
0
 public override object EditValue(
     System.ComponentModel.ITypeDescriptorContext context,
     IServiceProvider provider, object value)
 {
     if (provider != null)
     {
         IWindowsFormsEditorService edSvc
             = (IWindowsFormsEditorService)provider.GetService(
                   typeof(IWindowsFormsEditorService));
         if (edSvc == null)
         {
             return(value);
         }
         SelectResourceDialog srd
             = new SelectResourceDialog(this.mMgr);
         if (edSvc.ShowDialog(srd) !=
             System.Windows.Forms.DialogResult.OK)
         {
             return(value);
         }
         ResourceMgr.ResEntry res = srd.SelectedResource;
         if (res == null)
         {
             return(value);
         }
         Type t   = value.GetType();
         RK   key = new RK(this.mTID, res.GID, res.IID);
         if (t.Equals(typeof(RK)))
         {
             return(key);
         }
         if (t.IsInterface &&
             typeof(IResourceKey).IsAssignableFrom(t))
         {
             return(key);
         }
         if (t.Equals(typeof(string)))
         {
             return(key.ToString());
         }
     }
     return(value);
 }
Esempio n. 28
0
 public override object EditValue(
     System.ComponentModel.ITypeDescriptorContext context,
     IServiceProvider provider, object value)
 {
     if (provider != null)
     {
         IWindowsFormsEditorService edSvc
             = (IWindowsFormsEditorService)provider.GetService(
                 typeof(IWindowsFormsEditorService));
         if (edSvc == null)
         {
             return value;
         }
         SelectResourceDialog srd
             = new SelectResourceDialog(this.mMgr);
         if (edSvc.ShowDialog(srd) !=
             System.Windows.Forms.DialogResult.OK)
         {
             return value;
         }
         ResourceMgr.ResEntry res = srd.SelectedResource;
         if (res == null)
         {
             return value;
         }
         Type t = value.GetType();
         RK key = new RK(this.mTID, res.GID, res.IID);
         if (t.Equals(typeof(RK)))
         {
             return key;
         }
         if (t.IsInterface &&
             typeof(IResourceKey).IsAssignableFrom(t))
         {
             return key;
         }
         if (t.Equals(typeof(string)))
         {
             return key.ToString();
         }
     }
     return value;
 }
Esempio n. 29
0
        private void ParseIID()
        {
            ulong iid = 0;

            if (this.mName.Length == 0)
            {
                iid = FNVHash.HashString64(this.mName);
                this.bNameIsValid = false;
            }
            else if (RK.TryParseHex64(this.mName, out iid))
            {
                this.bNameIsValid = this.AllowHexNumberName;
            }
            else
            {
                iid = FNVHash.HashString64(this.mName);
                this.bNameIsValid = true;
            }
            this.mKey.IID = iid;
        }
Esempio n. 30
0
        private void resCellValidating(object sender,
                                       DataGridViewCellValidatingEventArgs e)
        {
            if (e.RowIndex < this.mResources.Length)
            {
                uint            val32;
                ulong           val64;
                DataGridViewRow row = this.resDGV.Rows[e.RowIndex];
                row.ErrorText = "";
                string str = e.FormattedValue.ToString();
                switch ((ColumnName)e.ColumnIndex)
                {
                case ColumnName.TID:
                    if (!RK.TryParseUInt32(str, out val32))
                    {
                        e.Cancel      = true;
                        row.ErrorText = "Type ID " +
                                        "must be a 32-bit unsigned integer";
                    }
                    break;

                case ColumnName.GID:
                    if (!RK.TryParseUInt32(str, out val32))
                    {
                        e.Cancel      = true;
                        row.ErrorText = "Group ID " +
                                        "must be a 32-bit unsigned integer";
                    }
                    break;

                case ColumnName.IID:
                    if (!RK.TryParseUInt64(str, out val64))
                    {
                        e.Cancel      = true;
                        row.ErrorText = "Type ID " +
                                        "must be a 64-bit unsigned integer";
                    }
                    break;
                }
            }
        }
Esempio n. 31
0
        private static List <RK> ParseRKsFromClipboard()
        {
            string str = Clipboard.GetText();

            if (string.IsNullOrEmpty(str))
            {
                return(null);
            }
            string[]  rkStrs = str.Split('\n');
            RK        rk;
            List <RK> rks = new List <RK>(rkStrs.Length);

            for (int i = 0; i < rkStrs.Length; i++)
            {
                if (RK.TryParse(rkStrs[i], out rk))
                {
                    rks.Add(rk);
                }
            }
            return(rks);
        }
Esempio n. 32
0
        /// <summary>
        /// Extracting the data from the stream
        /// </summary>
        public override void extractData()
        {
            BiffHeader bh, latestbiff;
            BOF        firstBOF = null;

            //try
            //{
            while (this.StreamReader.BaseStream.Position < this.StreamReader.BaseStream.Length)
            {
                bh.id     = (RecordType)this.StreamReader.ReadUInt16();
                bh.length = this.StreamReader.ReadUInt16();

                // TraceLogger.DebugInternal("BIFF {0}\t{1}\t", bh.id, bh.length);
                Console.WriteLine("WORKSHEET-BIFF {0}\t{1}\t", bh.id, bh.length);

                switch (bh.id)
                {
                case RecordType.EOF:
                {
                    this.StreamReader.BaseStream.Seek(0, SeekOrigin.End);
                }
                break;

                case RecordType.BOF:
                {
                    var bof = new BOF(this.StreamReader, bh.id, bh.length);

                    switch (bof.docType)
                    {
                    case BOF.DocumentType.WorkbookGlobals:
                    case BOF.DocumentType.Worksheet:
                        firstBOF = bof;
                        break;

                    case BOF.DocumentType.Chart:
                        // parse chart

                        break;

                    default:
                        this.readUnknownFile();
                        break;
                    }
                }
                break;

                case RecordType.LabelSst:
                {
                    var labelsst = new LabelSst(this.StreamReader, bh.id, bh.length);
                    this.bsd.addLabelSST(labelsst);
                }
                break;

                case RecordType.MulRk:
                {
                    var mulrk = new MulRk(this.StreamReader, bh.id, bh.length);
                    this.bsd.addMULRK(mulrk);
                }
                break;

                case RecordType.Number:
                {
                    var number = new Number(this.StreamReader, bh.id, bh.length);
                    this.bsd.addNUMBER(number);
                }
                break;

                case RecordType.RK:
                {
                    var rk = new RK(this.StreamReader, bh.id, bh.length);
                    this.bsd.addRK(rk);
                }
                break;

                case RecordType.MergeCells:
                {
                    var mergecells = new MergeCells(this.StreamReader, bh.id, bh.length);
                    this.bsd.MERGECELLSData = mergecells;
                }
                break;

                case RecordType.Blank:
                {
                    var blankcell = new Blank(this.StreamReader, bh.id, bh.length);
                    this.bsd.addBLANK(blankcell);
                } break;

                case RecordType.MulBlank:
                {
                    var mulblank = new MulBlank(this.StreamReader, bh.id, bh.length);
                    this.bsd.addMULBLANK(mulblank);
                }
                break;

                case RecordType.Formula:
                {
                    var formula = new Formula(this.StreamReader, bh.id, bh.length);
                    this.bsd.addFORMULA(formula);
                    TraceLogger.DebugInternal(formula.ToString());
                }
                break;

                case RecordType.Array:
                {
                    var array = new ARRAY(this.StreamReader, bh.id, bh.length);
                    this.bsd.addARRAY(array);
                }
                break;

                case RecordType.ShrFmla:
                {
                    var shrfmla = new ShrFmla(this.StreamReader, bh.id, bh.length);
                    this.bsd.addSharedFormula(shrfmla);
                }
                break;

                case RecordType.String:
                {
                    var formulaString = new STRING(this.StreamReader, bh.id, bh.length);
                    this.bsd.addFormulaString(formulaString.value);
                }
                break;

                case RecordType.Row:
                {
                    var row = new Row(this.StreamReader, bh.id, bh.length);
                    this.bsd.addRowData(row);
                }
                break;

                case RecordType.ColInfo:
                {
                    var colinfo = new ColInfo(this.StreamReader, bh.id, bh.length);
                    this.bsd.addColData(colinfo);
                }
                break;

                case RecordType.DefColWidth:
                {
                    var defcolwidth = new DefColWidth(this.StreamReader, bh.id, bh.length);
                    this.bsd.addDefaultColWidth(defcolwidth.cchdefColWidth);
                }
                break;

                case RecordType.DefaultRowHeight:
                {
                    var defrowheigth = new DefaultRowHeight(this.StreamReader, bh.id, bh.length);
                    this.bsd.addDefaultRowData(defrowheigth);
                }
                break;

                case RecordType.LeftMargin:
                {
                    var leftm = new LeftMargin(this.StreamReader, bh.id, bh.length);
                    this.bsd.leftMargin = leftm.value;
                }
                break;

                case RecordType.RightMargin:
                {
                    var rightm = new RightMargin(this.StreamReader, bh.id, bh.length);
                    this.bsd.rightMargin = rightm.value;
                }
                break;

                case RecordType.TopMargin:
                {
                    var topm = new TopMargin(this.StreamReader, bh.id, bh.length);
                    this.bsd.topMargin = topm.value;
                }
                break;

                case RecordType.BottomMargin:
                {
                    var bottomm = new BottomMargin(this.StreamReader, bh.id, bh.length);
                    this.bsd.bottomMargin = bottomm.value;
                }
                break;

                case RecordType.Setup:
                {
                    var setup = new Setup(this.StreamReader, bh.id, bh.length);
                    this.bsd.addSetupData(setup);
                }
                break;

                case RecordType.HLink:
                {
                    long oldStreamPos = this.StreamReader.BaseStream.Position;
                    try
                    {
                        var hlink = new HLink(this.StreamReader, bh.id, bh.length);
                        this.bsd.addHyperLinkData(hlink);
                    }
                    catch (Exception ex)
                    {
                        this.StreamReader.BaseStream.Seek(oldStreamPos, System.IO.SeekOrigin.Begin);
                        this.StreamReader.BaseStream.Seek(bh.length, System.IO.SeekOrigin.Current);
                        TraceLogger.Debug("Link parse error");
                        TraceLogger.Error(ex.StackTrace);
                    }
                }
                break;

                case RecordType.MsoDrawing:
                {
                    // Record header has already been read. Reset position to record beginning.
                    this.StreamReader.BaseStream.Position -= 2 * sizeof(ushort);
                    this.bsd.ObjectsSequence = new ObjectsSequence(this.StreamReader);
                }
                break;

                default:
                {
                    // this else statement is used to read BiffRecords which aren't implemented
                    var buffer = new byte[bh.length];
                    buffer = this.StreamReader.ReadBytes(bh.length);
                }
                break;
                }
                latestbiff = bh;
            }
            //}
            //catch (Exception ex)
            //{
            //    TraceLogger.Error(ex.Message);
            //    TraceLogger.Error(ex.StackTrace);
            //    TraceLogger.Debug(ex.ToString());
            //}
        }
Esempio n. 33
0
        protected override Stream UnParse()
        {
            if (ppt == null)
            {
                throw new InvalidOperationException("PathPackageTuple must not be null.");
            }

            if (packageid == null)
            {
                throw new InvalidOperationException("PackageId must not be null.");
            }

            if (packagetype == null)
            {
                throw new InvalidOperationException("Type of package must not be null.");
            }

            Document = new XmlDocument();
            XmlElement root = Document.CreateElement("manifest");

            Document.AppendChild(root);

            root.SetAttribute("packagesubtype", subtype);
            root.SetAttribute("packagetype", packagetype);
            root.SetAttribute("version", "3");
            root.SetAttribute("true", "false");

            root.AppendChild(CreateElement("gameversion", "0.0.0.11195"));
            root.AppendChild(CreateElement("packagedate", DateTime.UtcNow.ToString("MM/dd/yyyy")));
            root.AppendChild(CreateElement("assetversion", "0"));
            root.AppendChild(CreateElement("mingamever", "1.0.0.0"));
            root.AppendChild(Document.CreateElement("handler"));
            root.AppendChild(CreateDefaultDependencyList());
            root.AppendChild(CreateElement("packageid", packageid));

            root.AppendChild(CreateNumOfThumbs());

            KeyList = Document.CreateElement("keylist");
            ppt.Package.GetResourceList.ForEach(Add);
            root.AppendChild(KeyList);

            if (createMissingThumb && numofthumbs == 0)
            {
                RK newRK;
                System.Drawing.Image newIcon;
                SpecificResource     srKey = FindLargestThumb();
                if (srKey != null)
                {
                    newRK = new RK(srKey.ResourceIndexEntry)
                    {
                        ResourceType = 0x2E75C765,
                    };
                    newIcon = System.Drawing.Image.FromStream(srKey.Resource.Stream);
                }
                else
                {
                    srKey = ppt.Find(x => x.ResourceType == 0x0166038C);
                    if (srKey != null)
                    {
                        newRK = new RK(srKey.ResourceIndexEntry)
                        {
                            ResourceType = 0x2E75C765,
                        }
                    }
                    ;
                    else
                    {
                        newRK = new RK(RK.NULL)
                        {
                            ResourceType  = 0x2E75C765,
                            ResourceGroup = 0,
                            Instance      = System.Security.Cryptography.FNV64.GetHash(Path.GetFileNameWithoutExtension(ppt.Path))
                        };
                    }
                    newIcon = S3Pack.Properties.Resources.defaultIcon;
                }
                if (newIcon.Width != 256)
                {
                    newIcon = newIcon.GetThumbnailImage(256, 256, () => false, System.IntPtr.Zero);
                }
                MemoryStream ms = new MemoryStream();
                newIcon.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                Add(ppt.AddResource(newRK, ms).ResourceIndexEntry);
            }

            root.AppendChild(CreateLanguageElementWithChild("localizednames", "localizedname", title));
            root.AppendChild(CreateElement("packagetitle", title));
            root.AppendChild(CreateLanguageElementWithChild("localizeddescriptions", "localizeddescription", desc));
            root.AppendChild(CreateElement("packagedesc", desc));

            byte[]       res;
            MemoryStream msXml = new MemoryStream();

            using (XmlWriter xw = XmlWriter.Create(msXml, new XmlWriterSettings()
            {
                CloseOutput = false,
                Encoding = System.Text.UTF8Encoding.UTF8,
                Indent = true,
                IndentChars = "  ",
                NewLineChars = "\n",
            }))
            {
                Document.Save(xw);
                xw.Flush();
                xw.Close();
                res = msXml.ToArray();
            }
            return(msXml);
        }
Esempio n. 34
0
        private void resCellValuePushed(object sender,
                                        DataGridViewCellValueEventArgs e)
        {
            if (e.RowIndex < this.mResources.Length)
            {
                uint   val32;
                ulong  val64;
                string str = e.Value == null ? null : e.Value.ToString();
                INamedResourceIndexEntry rie = this.mResources[e.RowIndex];
                switch ((ColumnName)e.ColumnIndex)
                {
                case ColumnName.Tag:
                    string[] strs = str.Split(' ');
                    if (RK.TryParseHex32(strs[1], out val32))
                    {
                        rie.ResourceType = val32;
                    }
                    if (this.mColIndex == (int)ColumnName.Tag ||
                        this.mColIndex == (int)ColumnName.TID)
                    {
                        if (this.CheckResDGVSorted(e.RowIndex))
                        {
                            this.resDGV.UpdateCellValue(
                                (int)ColumnName.TID, e.RowIndex);
                        }
                        else
                        {
                            this.UpdateResDGV();
                        }
                    }
                    else
                    {
                        this.resDGV.UpdateCellValue(
                            (int)ColumnName.TID, e.RowIndex);
                    }
                    if (this.bDetectConflicts)
                    {
                        this.ClearConflictHighlighting();
                        this.HighlightConflicts();
                    }
                    break;

                case ColumnName.TID:
                    if (RK.TryParseUInt32(str, out val32))
                    {
                        rie.ResourceType = val32;
                    }
                    if (this.mColIndex == (int)ColumnName.Tag ||
                        this.mColIndex == (int)ColumnName.TID)
                    {
                        if (this.CheckResDGVSorted(e.RowIndex))
                        {
                            this.resDGV.UpdateCellValue(
                                (int)ColumnName.Tag, e.RowIndex);
                        }
                        else
                        {
                            this.UpdateResDGV();
                        }
                    }
                    else
                    {
                        this.resDGV.UpdateCellValue(
                            (int)ColumnName.Tag, e.RowIndex);
                    }
                    if (this.bDetectConflicts)
                    {
                        this.ClearConflictHighlighting();
                        this.HighlightConflicts();
                    }
                    break;

                case ColumnName.GID:
                    if (RK.TryParseUInt32(str, out val32))
                    {
                        rie.ResourceGroup = val32;
                    }
                    if (this.mColIndex == (int)ColumnName.GID &&
                        !this.CheckResDGVSorted(e.RowIndex))
                    {
                        this.UpdateResDGV();
                    }
                    if (this.bDetectConflicts)
                    {
                        this.ClearConflictHighlighting();
                        this.HighlightConflicts();
                    }
                    break;

                case ColumnName.IID:
                    if (RK.TryParseUInt64(str, out val64))
                    {
                        rie.Instance = val64;
                    }
                    if (this.mColIndex == (int)ColumnName.IID &&
                        !this.CheckResDGVSorted(e.RowIndex))
                    {
                        this.UpdateResDGV();
                    }
                    if (this.bDetectConflicts)
                    {
                        this.ClearConflictHighlighting();
                        this.HighlightConflicts();
                    }
                    break;

                case ColumnName.Comp:
                    bool comp = (bool)e.Value;
                    rie.Compressed = (ushort)(comp ? 0xFFFF : 0x0000);
                    if (this.mColIndex == (int)ColumnName.Comp &&
                        !this.CheckResDGVSorted(e.RowIndex))
                    {
                        this.UpdateResDGV();
                    }
                    break;

                case ColumnName.Name:
                    rie.ResourceName = str;
                    if (this.mAutoHashing != Hashing.None)
                    {
                        val64 = 0;
                        if (str != null)
                        {
                            switch (this.mAutoHashing)
                            {
                            case Hashing.FNV32:
                                val64 = FNVHash.HashString32(str);
                                break;

                            case Hashing.FNV64:
                                val64 = FNVHash.HashString64(str);
                                break;

                            case Hashing.FNVCLIP:
                                val64 = FNVCLIP.HashString(str);
                                break;
                            }
                        }
                        rie.Instance = val64;
                        if (this.mColIndex == (int)ColumnName.IID ||
                            this.mColIndex == (int)ColumnName.Name)
                        {
                            if (this.CheckResDGVSorted(e.RowIndex))
                            {
                                this.resDGV.UpdateCellValue(
                                    (int)ColumnName.IID, e.RowIndex);
                            }
                            else
                            {
                                this.UpdateResDGV();
                            }
                        }
                        else
                        {
                            this.resDGV.UpdateCellValue(
                                (int)ColumnName.IID, e.RowIndex);
                        }
                        if (this.bDetectConflicts)
                        {
                            this.ClearConflictHighlighting();
                            this.HighlightConflicts();
                        }
                    }
                    if (this.mColIndex == (int)ColumnName.Name &&
                        !this.CheckResDGVSorted(e.RowIndex))
                    {
                        this.UpdateResDGV();
                    }
                    break;
                }
            }
        }
Esempio n. 35
0
        private void rtContextMenu_Opening(object sender, CancelEventArgs e)
        {
            IResourceKey rk;

            rtgiPasteRK.Enabled = Clipboard.ContainsText() && RK.TryParse(Clipboard.GetText(), out rk);
        }