示例#1
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;
        }
示例#2
0
        private void ReflectAction()
        {
            // Displays the details of the action at the bottom
            pnlActionSelected.SuspendLayout();
            ctrActionColour.Visible  = false;
            chkActionKeyAuto.Visible = false;
            txtActionKey.Visible     = false;
            switch (m_Action.Change)
            {
            case Parameters.LineColour:
            case Parameters.FillColour:
            case Parameters.TextColour:
                ctrActionColour.Visible       = true;
                ctrActionColour.CurrentColour = Color.FromArgb((m_Action as ParameterAction).Value);
                lblActionSelected.Text        = Strings.Item("Button_SelectedAction") + " " + ParameterSupport.GetParameterTypeName(m_Action.Change) + " = ";
                break;

            case Parameters.Action_Key:
            case Parameters.Action_Character:
            case Parameters.Action_Text:
                chkActionKeyAuto.Visible = true;
                txtActionKey.Visible     = true;
                // doesn't use action description because this will include the key as well, which looks odd when it is in the box
                if (m_Action.Change == Parameters.Action_Key)
                {
                    txtActionKey.Text      = GUIUtilities.KeyDescription((m_Action as KeyAction).Key);
                    chkActionKeyAuto.Text  = Strings.Item("Button_ActionKeyAuto");
                    lblActionSelected.Text = Strings.Item("Button_SelectedAction") + " " + Strings.Item("Action_SimulateKey");
                }
                else
                {
                    txtActionKey.Text      = (m_Action as TextAction).Text;
                    chkActionKeyAuto.Text  = Strings.Item("Button_ActionCharacterAuto");
                    lblActionSelected.Text = Strings.Item("Button_SelectedAction") + " " + Strings.Item(m_Action.Change == Parameters.Action_Text ? "Action_TypeText" : "Action_TypeCharacter");
                }
                break;

            default:
                lblActionSelected.Text = Strings.Item("Button_SelectedAction") + " " + m_Action.DescriptionWithoutAccelerator();
                break;
            }
            pnlActionSelected.ResumeLayout();
        }
示例#3
0
文件: Command.cs 项目: stuart2w/SAW
 /// <summary>Returns the description of this command when adding it</summary>
 public virtual string GetDescription()
 {
     return(Strings.Item("Script_Desc_" + Code.ToUpper()));
 }
示例#4
0
 public override string StatusInformation(bool ongoing)
 {
     if (ongoing)
     {
         return(base.StatusInformation(true));                // display length of current edge
     }
     return(Strings.Item("Info_EqualEdge") + ": " + Measure.FormatLength(Geometry.DistanceBetween(Vertices[1], Vertices[2])) + "  " + Strings.Item("Info_OddEdge") + ": " + Measure.FormatLength(Geometry.DistanceBetween(Vertices[1], Vertices[0])));
 }
示例#5
0
        private async void DoSearch()
        {
            SetInfo(null, false);
            ClearImages();
            string text = txtText.Text;

            if (text.Length < MINCHARS)
            {
                m_Message = Strings.Item("SAW_Edit_OS_TooShort").Replace("%0", MINCHARS.ToString());
                return;
            }

            m_Message = Strings.Item("SAW_Edit_OS_Contacting");
            pnlImages.Invalidate();

            try
            {
                // sample URL: https://www.opensymbols.org/api/v1/symbols/search?q=house
                string searchResult = await GetStringAsync(@"https://www.opensymbols.org/api/v1/symbols/search?q=" + Uri.EscapeUriString(text));

                pnlImages.Invalidate();

                var json = JArray.Parse(searchResult);
                if (json.Count == 0)
                {
                    m_Message = Strings.Item("SAW_Edit_OS_NoneFound");
                }
                else
                {
                    if (json.Count > MAXIMAGES)
                    {
                        SetInfo(Strings.Item("SAW_Edit_OS_TooMany").Replace("%0", json.Count.ToString()).Replace("%1", MAXIMAGES.ToString()), true);
                    }
                    int failures = 0;
                    foreach (JObject imageJson in json.Take(MAXIMAGES))
                    {
                        try
                        {
                            DisplayedImage image = await GetImage(imageJson);

                            if (image != null)
                            {
                                if (m_Message != null)                                 // remove message, if any, once first image is displayed
                                {
                                    m_Message = null;
                                    pnlImages.Invalidate();
                                }
                                ShowPicture(image);
                            }
                        }
                        catch (Exception ex)
                        {
                            Utilities.LogSubError("Image " + (imageJson["symbol_key"]?.ToString() ?? "?") + " failed: " + ex.Message);
                            failures += 1;
                        }
                    }
                    if (failures > 0)
                    {
                        SetInfo(Strings.Item("SAW_Edit_OS_SomeFailed").Replace("%0", failures.ToString()), true);
                    }
                }
            }
            catch (Exception ex)
            {
                m_Message = Strings.Item("SAW_Edit_OS_Failed") + ex.Message;
                Utilities.LogSubError(ex);
            }
            pnlImages.Invalidate();
        }
示例#6
0
 public void btnSpeechTest_Click(object sender, EventArgs e)
 {
     Globals.Root.Speech.SettingsChanged(m_Applied);             // in order to apply any changes to volume, speed, pitch
     Globals.Root.Speech.Speak(Strings.Item("Config_SpeechTestText"));
     WrittenToCurrent();
 }
示例#7
0
文件: KeySend.cs 项目: stuart2w/SAW
        private KeySend()
        {
            m_QuestionVirtualKey = BitConverter.GetBytes(Windows.VkKeyScan('?'));

            LockCode         = Strings.Item("KeyScript__Lock").ToLower();
            HoldCode         = Strings.Item("KeyScript__Hold").ToLower();
            PressCode        = Strings.Item("KeyScript__Press").ToLower();
            ReleaseCode      = Strings.Item("KeyScript__Release").ToLower();
            UnlockCode       = Strings.Item("KeyScript__Unlock").ToLower();
            GIDEI_EscapeCode = Strings.Item("KeyScript__GIDEI_Escape").ToLower();
            OnCode           = Strings.Item("KeyScript__On").ToLower();
            OffCode          = Strings.Item("KeyScript__Off").ToLower();
            RepeatCode       = Strings.Item("KeyScript__Repeat").ToLower() + " ";       // note this includes the space (will have been trimmed by Strings even if in file)
            EndRepeatCode    = Strings.Item("KeyScript__EndRepeat").ToLower();
            DelayCode        = Strings.Item("KeyScript__Delay").ToLower();

            foreach (string key in Strings.Keys)             // Bit naff scanning them all, but I'd rather just keep them all in the same text file as usual
            {
                if (key.StartsWith("KeyScript_"))
                {
                    string right = key.Substring(10);                     // 10 = "KeyScript_".Length
                    // After this should either be GIDEI_xyz or NEW_xyz or _whatever (last is for any text which is not a key, but needed here)
                    if (right.StartsWith("GIDEI_"))
                    {
                        right = right.Substring(6);
                        // the rest of the name is the keycode.  The text is the user text
                        // text system won't allow 2 lines with the same ID, so single apostrophes can be appended to the ID, and these are removed here to get the actual key name
                        Keys   keyCode = (Keys)Enum.Parse(typeof(Keys), right.Trim('\''));
                        string name    = Strings.Item(key).ToLower();
                        m_GIDEICodes.Add(name, keyCode);
                    }
                    else if (right.StartsWith("NEW_"))
                    {
                        right = right.Substring(4);
                        // the rest of the name is the keycode.  The text is the user text
                        Keys   keyCode = (Keys)Enum.Parse(typeof(Keys), right.Trim('\''));                       // permits the ' as above, but shouldn't be needed?
                        string name    = Strings.Item(key).ToLower();
                        m_NewCodes.Add(name, keyCode);
                        if (!m_NewCodesReverse.ContainsKey(keyCode))
                        {
                            m_NewCodesReverse.Add(keyCode, name);
                        }
                    }
                }
            }
            foreach (Keys key in Enum.GetValues(typeof(Keys)))
            {
                string name  = key.ToString();
                string lower = name.ToLower();
                if (name.Length > 1)                // ignore single letters!
                {
                    if (!m_NewCodes.ContainsKey(lower))
                    {
                        // and keys in translations have priority
                        m_NewCodes.Add(lower, key);
                        if (!m_NewCodesReverse.ContainsKey(key))
                        {
                            m_NewCodesReverse.Add(key, name);
                        }
                    }
                    if (!m_GIDEICodes.ContainsKey(lower))
                    {
                        m_GIDEICodes.Add(lower, key);
                    }
                }
            }
        }
示例#8
0
        public frmSAWItem(List <Item> items, List <Scriptable> scriptables, Transaction transaction)
        {
            m_Filling = true;             // cleared by Fill
            InitializeComponent();
            Strings.Translate(this);
            // setting these 2 in editor makes their position go nuts while editing
            lblLargerRatio.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            ctrTextRatio.Anchor   = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;

            m_Page = (items.FirstOrDefault() as Shape ?? scriptables.FirstOrDefault()).FindPage();
            if (!items.Any())
            {
                items.Add(new Item()
                {
                    StyleType = Item.ItemDisplayTypes.IDT_Item
                });
                EditingItems = false;
            }
            m_Items       = items;
            m_Scriptables = scriptables;
            m_Transaction = transaction;
            cmbShape.Items.Add(Strings.Item("Button_Rectangular"));
            cmbShape.Items.Add(Strings.Item("Button_Rounded"));
            cmbShape.Items.Add(Strings.Item("Button_Elliptical"));
            foreach (string s in new[] { "SAW_Edit_None", "SAW_Edit_Thin", "SAW_Edit_Medium", "SAW_Edit_Thick", "SAW_Edit_ExtraThick" })
            {
                cmbThicknessNormal.Items.Add(Strings.Item(s));
                cmbThicknessHighlight.Items.Add(Strings.Item(s));
            }
            cmbStyle.DataSource    = StyleOptions;
            cmbStyle.DisplayMember = "Text";
            cmbStyle.ValueMember   = "Style";
            rdoAlternate.Checked   = true;
            Fill();
            tmrPreview.Tick += m_tmrPreview_Tick;
            foreach (RadioButton r in grpGraphicAlignment.Controls)
            {
                r.CheckedChanged += GraphicAlign_CheckedChanged;
            }
            foreach (RadioButton r in grpTextAlignment.Controls)
            {
                r.CheckedChanged += TextAlign_CheckedChanged;
            }
            rdoTextAbove.CheckedChanged   += Alignment_CheckedChanged;
            rdoTextBelow.CheckedChanged   += Alignment_CheckedChanged;
            rdoTextLeft.CheckedChanged    += Alignment_CheckedChanged;
            rdoTextRight.CheckedChanged   += Alignment_CheckedChanged;
            rdoTextOverlay.CheckedChanged += Alignment_CheckedChanged;

            ShowStyleWarning();
            if (Globals.Root.CurrentConfig.ReadBoolean(Config.SAW_Prompts, true) == false)
            {
                lblHelpHeader.Text += " " + Strings.Item("SAW_Edit_Help_IsOff");
            }
            else if (Globals.Root.CurrentPage.HelpSAWID <= 0)
            {
                lblHelpHeader.Text += " " + Strings.Item("SAW_Edit_Help_NoItem");
            }

            if (!EditingItems)
            {
                tcMain.TabPages.Remove(tpLayout);
                //tcMain.TabPages.Remove(tpPresentation);
                tcMain.SelectedIndex = 2;                 // start on scripts

                lblStyleWarning.Enabled = false;          // style is left visible to avoid having an odd gap at top of page
                cmbStyle.Enabled        = false;
                lblItemStyle.Enabled    = false;
                lblBorderShape.Visible  = false;                // border shape is at bottom and can just be hidden
                cmbShape.Visible        = false;

                lblLineSpacing.Visible = txtDisplay.Visible = nudLineSpacing.Visible = chkShowText.Visible = btnFont.Visible = false;
                tablePresentation.RowStyles[2].SizeType = SizeType.AutoSize;
                chkOutputTextSame.Visible = chkSpeechTextSame.Visible = false;
                flowGraphic.Visible       = pnlGraphic.Visible = btnImageBrowse.Visible = btnImageClear.Visible = btnCCF.Visible = btnOpenSymbol.Visible = false;
                chkPopup.Visible          = chkWordlistCustom.Visible = chkEscapeItem.Visible = false;

                lblDisplayText.Text    = Strings.Item("SAW_Edit_GraphicPresentation");
                lblDisplayText.Font    = new Font(lblDisplayText.Font.FontFamily, 10);
                lblDisplayText.Padding = new Padding(0, 0, 0, 8);

                // add empty row at bottom to absorb spare space
                tablePresentation.RowCount += 1;
                tablePresentation.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
            }
        }
示例#9
0
 public override string StatusInformation(bool ongoing)
 {
     if (ongoing)
     {
         return(base.StatusInformation(true));
     }
     return(Strings.Item("Info_Edge") + ": " + Measure.FormatLength(Geometry.DistanceBetween(Vertices[0], Vertices[1])) + "  " + Strings.Item("Info_Sides") + ": " + m_Sides);
 }
示例#10
0
文件: KeySend.cs 项目: stuart2w/SAW
        /// <summary>Processes one token in new format;  the containing &lt;&gt; has already been removed</summary>
        private void ProcessNew(string token)
        {
            if (token == EndRepeatCode)
            {
                ProcessEndRepeat();
            }
            // must be before suffix stuff as this contains Return
            //else if (strToken == m_strEndRepeat)  // ?????
            //{
            //	ProcessEndRepeat();
            //	return;
            //}
            int    suffix          = token.LastIndexOf('_');
            Modes  mode            = Modes.Press;
            string remaining       = token;
            bool   modeWasExplicit = false;           // true if the mode was explicitly stated

            if (suffix > 0)
            {
                // ends _Hold _Release _Lock _Unlock
                if (token.Contains('+'))
                {
                    throw new UserException(Strings.Item("KeyScript__PlusUnderscore").Replace("%0", token));
                }
                if (suffix == token.Length - 1)
                {
                    throw new UserException(Strings.Item("KeyScript__InvalidSuffix").Replace("%0", token));
                }
                string command = token.Substring(suffix + 1);
                remaining = token.Substring(0, suffix);
                if (command == OffCode || command == OnCode)
                {
                    ProcessOnOff(remaining, command == OnCode, token);
                    return;
                }
                mode = LookupModeName(command);
                if (mode == Modes.None)
                {
                    throw new UserException(Strings.Item("KeyScript__InvalidSuffix").Replace("%0", token));
                }
                modeWasExplicit = true;
            }
            // single key
            if (token == ReleaseCode || token == UnlockCode)             // not in SAW 6, but like GIDEI a <rel> alone releases all
            {
                AddReleaseAll();
            }
            else if (token.StartsWith(RepeatCode))             // m_strRepeat includes final space required
            {
                ProcessRepeat(token);
            }
            else if (token.StartsWith(DelayCode))
            {
                int delay;
                if (!int.TryParse(token.Substring(DelayCode.Length), out delay))
                {
                    throw new UserException("Delay value not understood");
                }
                SendQueuedOutput();
                Thread.Sleep(delay);
            }
            else
            {
                while (!string.IsNullOrEmpty(remaining))                 // allows any number to be linked by +.  All keys before + are held regardless of whats after
                {
                    string keyName = remaining;
                    if (remaining.Contains("+"))
                    {
                        keyName   = remaining.Substring(0, remaining.IndexOf("+"));
                        remaining = remaining.Substring(remaining.IndexOf("+") + 1);
                    }
                    else
                    {
                        remaining = "";
                    }
                    Keys key = LookupNewKeyName(keyName, "<" + token + ">");
                    if (IsModifier(key))
                    {
                        AddCommand(mode == Modes.Press && !modeWasExplicit ? Modes.Hold : mode, key);                         // holds, unless overridden by _xyz
                    }
                    else
                    {
                        AddCommand(remaining == "" && !modeWasExplicit ? mode : Modes.Hold, key);                         // see above - keys before + automatically hold
                    }
                }
            }
        }
示例#11
0
 public override string StatusInformation(bool ongoing)
 {
     return(Strings.Item("Info_Sides") + ": " + m_DefinedVertices + "  " + base.StatusInformation(ongoing));
     // base does perimeter
 }
示例#12
0
 public frmCreateActivity(Transaction transaction)
 {
     m_OuterTransaction = transaction;
     InitializeComponent();
     pnlPreviewActivityIcon.NoImageString = Strings.Item("Intro_NoImage");
 }
示例#13
0
文件: Measure.cs 项目: stuart2w/SAW
        public static string FormatLength(float length)
        {
            Units units = CurrentUnits();

            return((length / UnitSizeInMM(units)).ToString(UnitNumberFormat(units)) + " " + Strings.Item(units.ToString()));
        }
示例#14
0
 public StyleOption(string str, Item.ItemDisplayTypes style)
 {
     Text  = Strings.Item(str);
     Style = style;
 }
示例#15
0
        private void DoStartupCheck(Action callbackWhenAvailable)
        {
            try
            {
                Repo2SoapClient server = new Repo2SoapClient("Repo2Soap", Server.TechURL + "repo2.asmx");
                string          latest = server.LastVersionB(Server.Software, Server.PRODUCT, SoftwareVersion.VersionString, "", false, Server.Language2, GetNetVersion(), GetMachineID());
                if (latest.StartsWith("w"))
                {
                    latest = latest.Substring(1);                     // ignore update-via-download flag;  all that's important is what version is available
                }
                // run the rest on UI thread
                Menu.Invoke(new Action(() =>
                {
                    var parts = latest.Split('#');
#if !DEBUG
                    for (int index = 1; index < parts.Length; index++)
                    {
                        // process any directives.They are in form "1.2.3#warn" - where each item between # is a command
                        switch (parts[index].ToLower())
                        {
                        case "warn":
                            const string SkipKey = "Skip_Upgrade_Message";
                            var skip             = Config.SystemConfig.ReadInteger(SkipKey, 0);
                            if (skip > 0)
                            {
                                Config.SystemConfig.Write(SkipKey, skip - 1);
                            }
                            else
                            {
                                Config.SystemConfig.Write(SkipKey, 10);
                                MessageBox.Show(Strings.Item("Update_Warn"));
                            }
                            SaveSystemConfig();
                            break;
                        }
                    }
#endif
                    latest = parts[0];

                    if (string.IsNullOrEmpty(latest))
                    {
                        return;
                    }
                    float asNumber  = SoftwareVersion.VersionNumberFromString(latest);
                    UpdateAvailable = asNumber > SoftwareVersion.Version + 0.001;                     // see frmUpdate

                    Config.SystemConfig.Write(CONFIG_UPDATECHECK_STATE, (int)StartState.Complete);
                    Globals.Root.SaveSystemConfig();
                    if (UpdateAvailable)
                    {
                        callbackWhenAvailable.Invoke();
                    }
                }));
            }
            catch (Exception ex)
            {
                try
                {
#if !DEBUG
                    Utilities.LogSubError(ex);
#endif
                }
                catch
                {
                }
            }
        }
示例#16
0
        private void Fill()
        {
            m_Filling       = true;
            txtDisplay.Text = m_Items.First().LabelText?.Replace("\r", "\r\n") ?? "";
            MergeBooleansIntoCheckbox(chkShowText, from i in m_Items select i.TextShown);
            if (m_Items.Count == 1)
            {
                nudLineSpacing.Value = m_Items.First().LineSpace;
            }
            else
            {
                txtDisplay.Text = Strings.Item("SAW_Edit_MultipleRestrictions");
            }

            txtHelp.Enabled = chkOutputTextSame.Enabled = chkSpeechTextSame.Enabled = txtOutputText.Enabled = txtSpeechText.Enabled = nudLineSpacing.Enabled = txtDisplay.Enabled = m_Items.Count == 1;
            // must be before check boxes are assigned, as they can also disable
            txtOutputText.Text        = m_Scriptables.First().OutputText;
            chkOutputTextSame.Checked = m_Scriptables.First().OutputAsDisplay;

            txtSpeechText.Text        = m_Scriptables.First().SpeechText;
            chkSpeechTextSame.Checked = m_Scriptables.First().SpeechAsDisplay;
            txtHelp.Text = m_Scriptables.First().PromptText;

            MergeBooleansIntoCheckbox(chkShowGraphic, from i in m_Items select i.GraphicShown);
            MergeBooleansIntoCheckbox(chkGraphicOnlyHighlight, from i in m_Items select i.GraphicOnlyOnHighlight);
            btnImageClear.Enabled = m_Items.Count == 1 && m_Items.Any(i => i.Image != null);
            btnCCF.Enabled        = btnImageBrowse.Enabled = m_Items.Count == 1;
            SetGraphicTooltip();

            // attributes:
            MergeBooleansIntoCheckbox(chkPopup, from s in m_Scriptables select s.Popup);
            MergeBooleansIntoCheckbox(chkWordlistCustom, from i in m_Items select i.WordlistDoesntFill);
            MergeBooleansIntoCheckbox(chkResetSwap, from s in m_Scriptables select s.ResetSwap);
            MergeBooleansIntoCheckbox(chkNotScanned, from s in m_Scriptables select s.NotVisited);
            MergeBooleansIntoCheckbox(chkAutoRepeatable, from s in m_Scriptables select s.AutoRepeat);
            MergeBooleansIntoCheckbox(chkEscapeItem, from i in m_Items select i.IsEscape);
            chkEscapeItem.Enabled = !m_Items.Any(i => i.IsGroup);             // group items will ignore escape flag

            // colour + style
            Item.ItemDisplayTypes?styletype = MergeStates(from i in m_Items select i.StyleType);
            if (styletype.HasValue)
            {
                cmbStyle.SelectedValue = styletype.Value;
            }
            MergeColoursIntoPicker(clrNormalText, from i in m_Items select i.TextStyle.Colour);
            MergeColoursIntoPicker(clrHighlightText, from s in m_Scriptables select s.HighlightStyle.TextColour);
            MergeBooleansIntoCheckbox(chkNormalFilled, from i in m_Items select i.FillStyle.Pattern != Shape.FillStyleC.Patterns.Empty);
            MergeColoursIntoPicker(clrNormalBack, from i in m_Items select i.FillStyle.Colour);
            MergeColoursIntoPicker(clrNormalBack, Parameters.FillColour);
            //MergeBooleansIntoCheckbox(chkHighlightFilled, from s in m_Scriptables select s.HighlightStyle.FillColour.A != 0);
            MergeColoursIntoPicker(clrHighlightBack, from s in m_Scriptables select s.HighlightStyle.FillColour);
            //MergeColoursIntoPicker(clrNormalBorder, from i in m_Items select i.LineStyle.Colour);
            MergeColoursIntoPicker(clrNormalBorder, Parameters.LineColour);
            MergeColoursIntoPicker(clrHighlightBorder, from s in m_Scriptables select s.HighlightStyle.LineColour);
            try
            {
                // Unlike ALL there is no "none" option.  That is implemented by setting the thickness to 0
                cmbShape.SelectedIndex              = MergeStates(from i in m_Items select(int) i.BorderShape) ?? -1;
                cmbThicknessNormal.SelectedIndex    = MergeStates(from i in m_Items select IntegerThickness(i.LineStyle.Width)) ?? -1;
                cmbThicknessHighlight.SelectedIndex = MergeStates(from s in m_Scriptables select IntegerThickness(s.HighlightStyle.LineWidth)) ?? -1;
            }
            catch             // Any invalid values will leave all at default
            {
                cmbShape.SelectedIndex              = 0;
                cmbThicknessNormal.SelectedIndex    = 2;
                cmbThicknessHighlight.SelectedIndex = 2;
            }
            // back colour enabled was set by property merge.  Copy to other controls:
            chkNormalFilled.Enabled = chkHighlightFilled.Enabled = clrHighlightBack.Enabled = clrNormalBack.Enabled;
            if (!clrNormalBack.Enabled)
            {
                lblBackColourHeader.Text += " " + Strings.Item("SAW_Edit_NA");
            }

            ButtonShape.Layouts?arrangement = MergeStates(from i in m_Items select i.Arrangement);
            if (arrangement.HasValue)             // if not, then no item is selected
            {
                switch (arrangement.Value)
                {                 // note sense is different: Layouts enum references graphic position
                case ButtonShape.Layouts.Below: rdoTextAbove.Checked = true; break;

                case ButtonShape.Layouts.Left: rdoTextRight.Checked = true; break;

                case ButtonShape.Layouts.Right: rdoTextLeft.Checked = true; break;

                case ButtonShape.Layouts.CentreBoth: rdoTextOverlay.Checked = true; break;

                //case ButtonShape.Layouts.Above:
                default: rdoTextBelow.Checked = true; break;
                }
            }
            float?textRatio = MergeStates(from i in m_Items select i.TextRatio);

            chkRatioAutomatic.Visible = ctrTextRatio.Visible = lblLargerRatio.Visible = lblSmallerRatio.Visible = lblTextRatioTitle.Visible = textRatio.HasValue;
            if (textRatio.HasValue)
            {
                ctrTextRatio.Value        = textRatio >= 0 ? (int)(textRatio * 100) : 50;
                chkRatioAutomatic.Checked = textRatio < 0;
            }

            uint        textAlignAsInt = (uint?)MergeStates(from i in m_Items select i.TextAlign) ?? 0xffff;
            RadioButton rdo            = (from RadioButton r in grpTextAlignment.Controls where r.Tag.ToString() == textAlignAsInt.ToString() select r).FirstOrDefault();

            if (rdo != null)
            {
                rdo.Checked = true;
            }
            uint graphicAlignAsInt = (uint?)MergeStates(from i in m_Items select i.TextAlign) ?? 0xffff;

            rdo = (from RadioButton r in grpGraphicAlignment.Controls where r.Tag.ToString() == graphicAlignAsInt.ToString() select r).FirstOrDefault();
            if (rdo != null)
            {
                rdo.Checked = true;
            }

            if (m_Scriptables.Count == 1)
            {
                ctrScripts.Edit(m_Scriptables.First());
                Text = Strings.Item("SAW_Edit_Item") + " : ID " + m_Scriptables.First().SAWID;
            }
            else
            {
                tcMain.TabPages.RemoveAt(3);
                Text = Strings.Item("SAW_Edit_Item_Multiple");
            }

            ReflectSoundButtons();
            m_Filling = false;
        }
示例#17
0
 public Folder(string code)
 {
     Code = code;
     Text = Strings.Item("Script_Group_" + code);
 }
示例#18
0
 public override string StatusInformation(bool ongoing)
 {
     return(Strings.Item("Info_Length") + ": " + Measure.FormatLength(Geometry.DistanceBetween(Vertices[0], Vertices[1])));
 }
示例#19
0
文件: Command.cs 项目: stuart2w/SAW
 /// <summary>This is called once when CommandList is being populated.  The object must fill in PossibleCommands, and can also use CustomData if desired</summary>
 internal virtual void CompleteCommandListEntry(CommandList.Entry entry)
 {
     entry.PossibleCommandsLower = new[] { Strings.Item("Script_Command_" + Code).ToLower() };
 }
示例#20
0
文件: frmPaper.cs 项目: stuart2w/SAW
        private void ReflectPaper()
        {
            if (m_Filling)
            {
                return;
            }
            m_Filling = true;
            try
            {
                rdoGraph.Checked  = m_Paper.PaperType == Paper.Papers.Graph;
                rdoPlain.Checked  = m_Paper.PaperType == Paper.Papers.Plain;
                rdoSquare.Checked = m_Paper.PaperType == Paper.Papers.Square;
                nudSize.Value     = Math.Min(nudSize.Maximum, (decimal)(m_Paper.PaperType == Paper.Papers.Ruled ? m_Paper.YInterval : m_Paper.XInterval));
                nudSize.Enabled   = m_Paper.PaperType != Paper.Papers.Plain;
                bool secondary = true;
                switch (m_Paper.PaperType)
                {
                case Paper.Papers.Graph:
                    nudSize.Increment          = 10;
                    nudSize.Value              = (decimal)Math.Min((float)nudSize.Maximum, m_Paper.XInterval * m_Paper.GraphMultiple);                // displays size of large box
                    nudSecondarySize.Increment = 1;
                    nudSecondarySize.Value     = m_Paper.GraphMultiple;
                    lblSize.Text          = Strings.Item("Paper_Size");
                    lblSecondarySize.Text = Strings.Item("Paper_GraphInterval");
                    break;

                case Paper.Papers.Square:
                    nudSize.Increment          = 5;
                    nudSecondarySize.Increment = 5;
                    nudSecondarySize.Value     = (decimal)m_Paper.YInterval;
                    lblSize.Text          = Strings.Item("Paper_XSize");
                    lblSecondarySize.Text = Strings.Item("Paper_YSize");
                    break;

                default:
                    secondary    = false;
                    lblSize.Text = Strings.Item("Paper_Size");
                    break;
                }
                nudSecondarySize.Visible   = secondary;
                lblSecondarySize.Visible   = secondary;
                chkDraw.Checked            = m_Paper.GridVisible;
                chkDotted.Checked          = m_Paper.Dotted;
                chkBigDots.Checked         = m_Paper.DotSize > Paper.STANDARDDOTSIZE;
                chkDraw.Enabled            = m_Paper.PaperType != Paper.Papers.Plain;
                chkDotted.Enabled          = chkDraw.Checked && chkDraw.Enabled && chkDraw.Enabled;
                chkBigDots.Enabled         = chkDotted.Checked;
                chkPrintBackground.Checked = m_Paper.PrintBackground;
                if (m_Paper.PaperType != Paper.Papers.Plain && nudSize.Value > 0)
                {
                    Paper.DefaultSpacing = (float)nudSize.Value;
                }
                ctrColour.CurrentColour     = m_Page.Colour;
                ctrGridColour.CurrentColour = m_Paper.GridColour;
                ctrGridColour.Visible       = m_Paper.GridVisible;
                lblGridColour.Visible       = m_Paper.GridVisible;
                pnlSample.Invalidate();
                lnkBackgroundImage.Text     = Strings.Item(m_Page.BackgroundImage == null ? "Paper_BackgroundImage" : "Paper_ChangeBackgroundImage");
                lnkRemoveBackground.Visible = m_Page.BackgroundImage != null;
                lnkBackgroundImage.Visible  = !m_Default;
                foreach (RadioButton rdo in m_ImageModes)
                {
                    rdo.Enabled = m_Page.BackgroundImage != null && !m_Default;
                }
                lblImageNoLockHeader.Enabled = lblImageModeHeader.Enabled = m_Page.BackgroundImage != null && !m_Default;
            }
            finally
            {
                m_Filling = false;
            }
        }
示例#21
0
 private void btnDefaultInfo_Click(object sender, EventArgs e)
 {
     MessageBox.Show(Strings.Item("SAW_Edit_DefaultInfo") + "\r\n" + (m_DefaultScript?.GenerateScript() ?? ""));
 }