コード例 #1
0
ファイル: MainForm.cs プロジェクト: dd-dk/sims3tools
        private void browserWidget1_SelectedResourceChanged(object sender, BrowserWidget.ResourceChangedEventArgs e)
        {
            resourceName = e.name;
            resource = null;
            resException = null;
            if (browserWidget1.SelectedResource != null)
            {
                try
                {
                    resource = s3pi.WrapperDealer.WrapperDealer.GetResource(0, CurrentPackage, browserWidget1.SelectedResource, controlPanel1.HexOnly);
                }
                catch (Exception ex)
                {
                    resException = ex;
                }
            }

            if (resource != null) resource.ResourceChanged += new EventHandler(resource_ResourceChanged);

            resourceIsDirty = controlPanel1.CommitEnabled = false;

            menuBarWidget1.ClearHelpers();

            controlPanel1_AutoChanged(null, null);
            if (resource != null)
            {
                controlPanel1.HexEnabled = true;
                controlPanel1.ValueEnabled = hasStringValueContentField();
                controlPanel1.GridEnabled = resource.ContentFields.Find(x => !x.Equals("AsBytes") && !x.Equals("Stream") && !x.Equals("Value")) != null;
                setHexEditor();
                setTextEditor();
                setHelpers();
            }
            else
            {
                controlPanel1.HexEnabled = controlPanel1.ValueEnabled = controlPanel1.GridEnabled =
                    controlPanel1.Helper1Enabled = controlPanel1.Helper2Enabled = controlPanel1.HexEditEnabled = false;
                menuBarWidget1.Enable(MenuBarWidget.MB.MBR_hexEditor, false);
                menuBarWidget1.Enable(MenuBarWidget.MB.MBR_textEditor, false);
                helpers = null;
            }

            bool selectedItems = resource != null || browserWidget1.SelectedResources.Count > 0; // one or more
            menuBarWidget1.Enable(MenuBarWidget.MB.MBR_exportResources, selectedItems);
            menuBarWidget1.Enable(MenuBarWidget.MB.MBR_exportToPackage, selectedItems);
            //menuBarWidget1.Enable(MenuBarWidget.MB.MBE_cut, resource != null);
            menuBarWidget1.Enable(MenuBarWidget.MB.MBR_copy, selectedItems);
            menuBarWidget1.Enable(MenuBarWidget.MB.MBR_duplicate, resource != null);
            menuBarWidget1.Enable(MenuBarWidget.MB.MBR_replace, resource != null);
            menuBarWidget1.Enable(MenuBarWidget.MB.MBR_compressed, selectedItems);
            menuBarWidget1.Enable(MenuBarWidget.MB.MBR_isdeleted, selectedItems);
            menuBarWidget1.Enable(MenuBarWidget.MB.MBR_details, resource != null);

            resourceFilterWidget1.IndexEntry = browserWidget1.SelectedResource;
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: dd-dk/sims3tools
        private void browserWidget1_SelectedResourceChanging(object sender, BrowserWidget.ResourceChangingEventArgs e)
        {
            if (resource == null) return;

            resource.ResourceChanged -= new EventHandler(resource_ResourceChanged);
            if (resourceIsDirty)
            {
                int dr = CopyableMessageBox.Show(
                    String.Format("Commit changes to {0}?",
                        e.name.Length > 0
                        ? e.name
                        : String.Format("TGI {0:X8}-{1:X8}-{2:X16}", browserWidget1.SelectedResource.ResourceType, browserWidget1.SelectedResource.ResourceGroup, browserWidget1.SelectedResource.Instance)
                    ), myName, CopyableMessageBoxButtons.YesNoCancel, CopyableMessageBoxIcon.Question, 1);
                if (dr == 2)
                {
                    e.Cancel = true;
                    return;
                }
                if (dr != 1)
                    controlPanel1_CommitClick(null, null);
            }
        }