Ejemplo n.º 1
0
        private void updateLists()
        {
            index   = -1;
            trcnres = (Trcn)(wrapper == null ? null : wrapper.SiblingResource(Trcn.Trcntype));

            this.lvConstants.Items.Clear();
            int nItems = wrapper == null ? 0 : wrapper.Count;

            for (int i = 0; i < nItems; i++)
            {
                this.lvConstants.Items.Add(lvItem(i));
            }
        }
Ejemplo n.º 2
0
        private void pjse_banner1_SiblingClick(object sender, EventArgs e)
        {
            Trcn trcn = (Trcn)wrapper.SiblingResource(Trcn.Trcntype);

            if (trcn == null)
            {
                return;
            }
            if (trcn.Package != wrapper.Package)
            {
                DialogResult dr = MessageBox.Show(Localization.GetString("OpenOtherPkg"), pjse_banner1.TitleText, MessageBoxButtons.YesNo);
                if (dr != DialogResult.Yes)
                {
                    return;
                }
            }
            SimPe.RemoteControl.OpenPackedFile(trcn.FileDescriptor, trcn.Package);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called by the AbstractWrapper when the file should be displayed to the user.
        /// </summary>
        /// <param name="wrp">Reference to the wrapper to be displayed.</param>
        public void UpdateGUI(IFileWrapper wrp)
        {
            wrapper = (Trcn)wrp;
            WrapperChanged(wrapper, null);
            pjse_banner1.SiblingEnabled = wrapper.SiblingResource(Bcon.Bcontype) != null;

            internalchg = true;
            updateLists();
            internalchg = false;

            setIndex(lvTrcnItem.Items.Count > 0 ? 0 : -1);

            if (!setHandler)
            {
                wrapper.WrapperChanged += new System.EventHandler(this.WrapperChanged);
                setHandler              = true;
            }
        }
Ejemplo n.º 4
0
        private void TRCNMaker()
        {
            bconPanel.Cursor          = Cursors.WaitCursor;
            Application.UseWaitCursor = true;
            try
            {
                int  minArgc = 0;
                Trcn trcn    = (Trcn)wrapper.SiblingResource(Trcn.Trcntype); // find Trcn for this Bcon

                wrapper.Package.BeginUpdate();

                if (trcn != null && trcn.TextOnly)
                {
                    // if it exists but is unreadable, as if user wants to overwrite
                    DialogResult dr = MessageBox.Show(
                        pjse.Localization.GetString("ml_overwriteduff")
                        , btnTRCNMaker.Text
                        , MessageBoxButtons.OKCancel
                        , MessageBoxIcon.Warning);
                    if (dr != DialogResult.OK)
                    {
                        return;
                    }
                    wrapper.Package.Remove(trcn.FileDescriptor);
                    trcn = null;
                }
                if (trcn != null)
                {
                    // if it exists ask if user wants to preserve content
                    DialogResult dr = MessageBox.Show(
                        pjse.Localization.GetString("ml_keeplabels")
                        , btnTRCNMaker.Text
                        , MessageBoxButtons.YesNoCancel
                        , MessageBoxIcon.Warning);
                    if (dr == DialogResult.Cancel)
                    {
                        return;
                    }

                    if (!trcn.Package.Equals(wrapper.Package))
                    {
                        // Clone the original into this package
                        if (dr == DialogResult.Yes)
                        {
                            Wait.MaxProgress = trcn.Count;
                        }
                        SimPe.Interfaces.Files.IPackedFileDescriptor npfd = trcn.FileDescriptor.Clone();
                        Trcn ntrcn = new Trcn();
                        ntrcn.FileDescriptor = npfd;
                        wrapper.Package.Add(npfd, true);
                        ntrcn.ProcessData(npfd, wrapper.Package);
                        if (dr == DialogResult.Yes)
                        {
                            foreach (TrcnItem item in trcn)
                            {
                                ntrcn.Add(item); Wait.Progress++;
                            }
                        }
                        trcn = ntrcn;
                        trcn.SynchronizeUserData();
                        Wait.MaxProgress = 0;
                    }

                    if (dr == DialogResult.Yes)
                    {
                        minArgc = trcn.Count;
                    }
                    else
                    {
                        trcn.Clear();
                    }
                }
                else
                {
                    // create a new Trcn file
                    SimPe.Interfaces.Files.IPackedFileDescriptor npfd = wrapper.FileDescriptor.Clone();
                    trcn                = new Trcn();
                    npfd.Type           = Trcn.Trcntype;
                    trcn.FileDescriptor = npfd;
                    wrapper.Package.Add(npfd, true);
                    trcn.SynchronizeUserData();
                }

                Wait.MaxProgress = wrapper.Count - minArgc;
                trcn.FileName    = wrapper.FileName;

                for (int arg = minArgc; arg < wrapper.Count; arg++)
                {
                    trcn.Add(new TrcnItem(trcn));
                    trcn[arg].ConstId   = (uint)arg;
                    trcn[arg].ConstName = "Label " + arg.ToString();
                    trcn[arg].DefValue  = trcn[arg].MaxValue = trcn[arg].MinValue = 0;
                    Wait.Progress++;
                }
                trcn.SynchronizeUserData();
                wrapper.Package.EndUpdate();
            }
            finally
            {
                Wait.SubStop();
                bconPanel.Cursor          = Cursors.Default;
                Application.UseWaitCursor = false;
            }
            MessageBox.Show(
                pjse.Localization.GetString("ml_done")
                , btnTRCNMaker.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }