예제 #1
0
        public AppliedConfig GenerateAppliedConfig(Users user, Document document)
        {
            AppliedConfig create = new AppliedConfig();

            for (Config.Levels level = Config.Levels._First; level <= Config.Levels._Last; level++)
            {
                if (level != Config.Levels.DocumentUser && level != Config.Levels.ActivityUser || user == Users.User)
                {
                    create.AddConfigAtEnd(GetCurrentConfig(level, document, user));
                }
            }
            return(create);
        }
예제 #2
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;
        }
예제 #3
0
        public RootApplication(frmMenu frm)
        {
#if DEBUG
            IsDebug = true;
#endif
            Menu = frm;
            m_Documents.Add(null);             // because the editor will just assign the current document into the current index

            // folders...
            EXEFolder      = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            InternalFolder = EXEFolder;

            SharedFolder = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), AppName);
            ConfigFolder = SharedFolder;
            bool sharedCreated = false;
            // create shared folder and set permissions
            try
            {
                if (!System.IO.Directory.Exists(SharedFolder))
                {
                    System.IO.Directory.CreateDirectory(SharedFolder);
                    System.Security.AccessControl.DirectorySecurity    dirSecurity = System.IO.Directory.GetAccessControl(SharedFolder);
                    System.Security.Principal.SecurityIdentifier       user        = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.BuiltinUsersSid, null);
                    System.Security.AccessControl.FileSystemAccessRule newRule     = new System.Security.AccessControl.FileSystemAccessRule(user, System.Security.AccessControl.FileSystemRights.FullControl,
                                                                                                                                            System.Security.AccessControl.InheritanceFlags.ContainerInherit | System.Security.AccessControl.InheritanceFlags.ObjectInherit, System.Security.AccessControl.PropagationFlags.None, System.Security.AccessControl.AccessControlType.Allow);
                    dirSecurity.AddAccessRule(newRule);
                    System.IO.Directory.SetAccessControl(SharedFolder, dirSecurity);

                    sharedCreated = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Cannot create required folder: " + SharedFolder + "\r\n" + "Error: " + ex);
                Application.Exit();
            }

#if DEBUG
            EXEFolder      = "d:\\data\\ace\\SAW\\Installer\\installer files";
            InternalFolder = EXEFolder;
            // config certainly needs to write back to the installation folder
            ConfigFolder = "d:\\data\\ace\\SAW\\test data";
            SharedFolder = "d:\\data\\ace\\SAW\\test data";
#else
            // Temporary version using folder location for everything
            //SharedFolder = EXEFolder + System.IO.Path.DirectorySeparatorChar + "Data";
            //ConfigFolder = SharedFolder;
#endif

            Globals.Root = this;
            try
            {
                Log                      = new CLogFile(SharedFolder + System.IO.Path.DirectorySeparatorChar + "log.txt");
                LogPermanent             = new CLogFile(SharedFolder + System.IO.Path.DirectorySeparatorChar + "permanent.txt", 100000);
                LogPermanent.TimeStampEx = TimeStamps.Date;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not create log files: " + ex.Message);
            }
            Log.WriteLine("Starting, version = " + SoftwareVersion.VersionString);
            Log.WriteLine("EXEFolder = " + EXEFolder);
            Log.WriteLine("SharedFolder = " + SharedFolder);
            Log.WriteLine("InternalFolder = " + InternalFolder);
            Log.WriteLine("OS = " + Environment.OSVersion);
            Log.WriteLine("64-bit = " + Environment.Is64BitOperatingSystem);
            Log.WriteLine("CLR = " + Environment.Version);
            Globals.CheckThemeOnStartup();

            if (sharedCreated)
            {
                // need to copy across from Splash 1 if applicable
                LogPermanent.WriteLine("Shared folder created");
            }

            Strings.Load();
            Log.WriteLine("SystemDPI = " + GUIUtilities.SystemDPI);

            Functions.Verb.CreateList();             // must before any configs loaded
            Functions.SAWVerbs.RegisterVerbs();

            // load configurations...
            Config.SystemConfig = LoadConfig("system" + Config.Extension, Config.Levels.System);
            Config.UserUser     = LoadConfig("User" + Config.Extension, Config.Levels.User, "user_Default" + Config.Extension);
            Config.UserUser.EnsureUserResources();
            if (!System.IO.Directory.Exists(Activities.ActivityConfigFolder))
            {
                System.IO.Directory.CreateDirectory(Activities.ActivityConfigFolder);
            }
            // activities are now loaded as needed

#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += frmErrorReport.UnhandledException;
            Application.ThreadException += frmErrorReport.ThreadException;
#else
            Config.Delta.ApplyV8Changes();
#endif
            CurrentConfig = new AppliedConfig();
            CurrentConfig.AddConfigAtEnd(Config.SystemConfig);
            CurrentConfig.AddConfigWithPriority(Config.UserUser);
        }