Example #1
0
        private readonly List <Config.Delta> m_colDeltas;        // list in the order that they are listed on the screen

#if DEBUG
        internal frmDeltas()
        {
            InitializeComponent();

            // remove folder stuff
            var colRemove = (from k in Config.SystemConfig.Values.Keys where k.StartsWith("Save_Folder_") || k.StartsWith("Open_Folder_") select k).ToList();

            foreach (var key in colRemove)
            {
                Config.SystemConfig.Values.Remove(key);
            }

            // Config.Delta constructor now removes value from configuration which shouldn't be included
            Dictionary <string, Config.Delta> deltas = new Dictionary <string, Config.Delta>();

            deltas.Add("System", new Config.Delta("System", Config.Levels.System));
            deltas.Add("User", new Config.Delta("User_Default", Config.Levels.User, "", null, Config.FromFile(Globals.Root.ConfigFolder + "\\user.sawcfg", Config.Levels.User)));
            //deltas.Add("Editor", new Config.Delta("Editor", Config.Levels.User));
            Activities.EnsureAllActivitiesLoaded();
            string folder = Globals.Root.ConfigFolder + "\\previous version configs";             // \\Activities";

            foreach (Document activity in Config.ActivityConfigs)
            {
                if (System.IO.File.Exists(folder + "\\" + activity.ID + ".sawcfg"))
                {
                    Document before = Config.FromFile(folder + "\\" + activity.ID + ".sawcfg", Config.Levels.ActivityUser).Document;
                    string   name   = Strings.Translate(before.Name);
                    deltas.Add(activity.UserSettings.ID.ToString(), new Config.Delta(activity.UserSettings.ID.ToString(), Config.Levels.ActivityUser, name + "_User", before.UserSettings, activity.UserSettings));
                    deltas.Add(activity.BothSettings.ID.ToString(), new Config.Delta(activity.BothSettings.ID.ToString(), Config.Levels.ActivityBoth, name + "_Both", before.BothSettings, activity.BothSettings));
                }
            }

            Config.SystemConfig.Write(Config.Delta_Applied, SoftwareVersion.Version);

            m_hashDeltas = deltas;
            m_colDeltas  = new List <Config.Delta>();
            foreach (string ID in deltas.Keys)
            {
                m_colDeltas.Add(deltas[ID]);
            }
            foreach (Config.Delta delta in m_colDeltas)
            {
                string text = delta.Name;
                if (delta.IsEmpty)
                {
                    text += " (empty)";
                }
                lstDeltas.Items.Add(text);
                // wipe any shape sequence:
                delta.After.ShapeSequence = null;
            }
            EnableSave();
            Config.UserUser.RecentFiles.Clear();
            Globals.Root.SaveAllActivityConfigs();
            Globals.Root.SaveUserConfigs();
            Globals.Root.SaveSystemConfig();
        }
Example #2
0
        public static Document Display(string file)
        {
            frmShowErrorReport frmNew = new frmShowErrorReport();

            frmNew.Text += " " + System.IO.Path.GetFileName(file);
            DataReader reader = new DataReader(file, FileMarkers.ErrorReport);
            //reader.ReadByte() ' Shouldn't be needed.  In versions 2.03.n if it failed to save the document it added an extra byte here (followed by a blank document)
            Document document = (Document)reader.ReadData(FileMarkers.Document);

            frmNew.txtError.Text   = reader.ReadString();
            frmNew.txtMessage.Text = reader.ReadString();
            List <string> colSubErrors = reader.ReadListString();

            System.Text.StringBuilder sub = new System.Text.StringBuilder();
            for (int index = 0; index <= colSubErrors.Count - 1; index++)
            {
                sub.Append("(").Append(index.ToString()).Append(") ").AppendLine(colSubErrors[index]);
            }
            frmNew.m_SubErrors      = sub.ToString();
            frmNew.txtErrorLog.Text = frmNew.m_SubErrors;
            // some of this extra information is not displayed yet, but is included in later reports
            reader.ReadByte();             //Dim eUser As Users =
            Guid idActivity = reader.ReadGuid();

            frmNew.m_UserConfig = (Config)reader.ReadData();
            reader.ReadData();             // will be null - UserEditor in Splash
            reader.ReadString();
            frmNew.m_Log          = reader.ReadString();
            frmNew.m_LogPermanent = reader.ReadString();
            if (reader.Version >= 108)
            {
                frmNew.m_Events = Globals.ReadDiagnosticEvents(reader);
            }
            reader.ReadOptionalPNG();             // never used
            reader.Close();
            document.UpdateReferencesObjectsCreated(document, reader);

            frmNew.lblVersion.Text = "Binary data version: " + reader.Version + "; Software version: " + SoftwareVersion.VersionStringFromNumber(reader.SoftwareVersion);
            if (document.Count == 0)
            {
                frmNew.lblWarning.Text = "SAW6Doc contained no pages - blank page created";
                document.AddPage(new Page(), new Transaction(), false);
            }
            frmNew.lblActivity.Text = "Activity: " + idActivity;
            try             // Error handler in case the activity is not present on this machine
            {
                frmNew.lblActivity.Text += " (" + Activities.GetActivityText(idActivity, false, false) + ")";
            }
            catch
            {
            }
            frmNew.TopMost = true;
            frmNew.Show();
            return(document);
        }
Example #3
0
        private Action m_Action;                    // cannot directly update m_Button because the View (on the original document) can have trouble rendering if the action is updated but not the image

        public frmButton(ButtonStyle style, ButtonShape button, Transaction transaction)
        {
            m_Filling = true;
            InitializeComponent();
            Strings.Translate(this);             // must not be in Load, as the data occasionally has translatable items
            Strings.Translate(mnuImage);

            m_Button        = button;
            m_Style         = style;     // must be before any parameters are attached
            m_OriginalStyle = style;
            m_Transaction   = transaction;
            m_Action        = button.Action;

            FillStylesList();
            ReflectCustomState();
            ctrStyle.DisplayStyle(m_Style);

            // content
            txtText.Text          = button.LabelText;
            pnlImagePreview.Image = button.GetImageForPreview();
            if (button.TextRatio < 0)
            {
                sldTextRatio.Value          = 50;
                rdoTextRatioDefault.Checked = true;
            }
            else
            {
                sldTextRatio.Value      = (int)(button.TextRatio * 100);
                rdoTextRatioSet.Checked = true;
            }
            pnlImagePreview.NoImageString = Strings.Item("Button_NoImage");
            PrepareLayout();
            pnlLayout.SelectedIndex = Math.Min((int)m_Button.Layout & ((int)ButtonShape.Layouts.Superimpose - 1), pnlLayout.Controls.Count - 1);
            chkSuperimpose.Checked  = (m_Button.Layout & ButtonShape.Layouts.Superimpose) > 0;
            ShowRatioAndLayout();

            // We need the configuration which will (probably) be in effect when the palette is used.  We assume user mode
            // as this is mainly to detect custom shapes.  Any available in user mode will also be available in teacher mode
            Document document = Globals.Root.CurrentDocument;             // document being edited; PROBABLY a palette, although buttons can be placed on pages ??

            if (document.PaletteWithin != null)
            {
                document = document.PaletteWithin.Document;
            }
            AppliedConfig applied = new AppliedConfig();

            applied.AddConfigAtEnd(document.UserSettings);             // Doesn't matter if any of the items passed to AddConfigAtEnd are nothing
            applied.AddConfigAtEnd(document.BothSettings);
            // Add the activity, if there is one specified in the document...
            if (!document.ActivityID.Equals(Guid.Empty))
            {
                Document activity = Activities.GetActivitySettings(document.ActivityID);
                if (activity != null)
                {
                    applied.AddConfigAtEnd(activity.UserSettings);
                    applied.AddConfigAtEnd(activity.BothSettings);
                }
            }
            applied.AddConfigAtEnd(Config.UserCurrent);             // User mode is assumed.  Any custom shapes only present in teacher mode will be ignored
            // (Note that the actions list isn't really interested in what is visible; only what is defined)
            applied.AddConfigAtEnd(Config.SystemConfig);
            ctrActions.Fill(applied);

            // Actions data
            chkDisplayFromAction.Checked = button.DisplayFromAction;
            ctrActions.SelectedAction    = m_Action;
            if (button.Action.Change == Parameters.Action_Key)
            {
                chkActionKeyAuto.Checked = !string.IsNullOrEmpty(button.LabelText) && button.LabelText[0].ToKeyData() == (button.Action as KeyAction).Key;
            }
            else if (button.Action.Change == Parameters.Action_Character)
            {
                chkActionKeyAuto.Checked = true;                 // I think the only way of achieving this is using the checkbox
            }
            else if (button.Action.Change == Parameters.Action_Text)
            {
                chkActionKeyAuto.Checked = button.LabelText == (button.Action as TextAction).Text;
            }
            ReflectAction();
            m_Filling = false;
        }