Exemple #1
0
        /// <summary>returns null if cancelled.  filename should be existing name for file, but only within folder</summary>
        public static string ShowSave(Context context, string filter = "", string filename = "")
        {
            Debug.Assert(!filename.Contains(System.IO.Path.DirectorySeparatorChar));
            Debug.Assert(context != Context.Image || !string.IsNullOrEmpty(filter), "FileDialog.ShowSave: filter should be specified when saving images");
            if (string.IsNullOrEmpty(filter))
            {
                filter = GetDefaultFilter(context);
            }
            if (g_dlgSave == null)
            {
                g_dlgSave = new SaveFileDialog();
            }
            string key      = SaveConfigKey(context);
            string existing = Globals.Root.CurrentConfig.ReadString(key);

            if (string.IsNullOrEmpty(existing))
            {
                existing = Globals.Root.CurrentConfig.ReadString(OpenConfigKey(context));                 // if the user has not manually saved yet, then use any open folder (probably where this document came from)
            }
            if (!string.IsNullOrEmpty(existing))
            {
                g_dlgSave.InitialDirectory = existing;
            }
            g_dlgSave.Filter   = Strings.Translate(filter);
            g_dlgSave.FileName = filename;
#if DEBUG
            g_dlgSave.OverwritePrompt = false;
#endif
            if (g_dlgSave.ShowDialog() != DialogResult.OK)
            {
                return(null);
            }
            Config.SystemConfig.Write(key, System.IO.Path.GetDirectoryName(g_dlgSave.FileName));
            return(g_dlgSave.FileName);
        }
Exemple #2
0
 public void frmMoreColours_Load(object sender, EventArgs e)
 {
     Strings.Translate(this);
     GUIUtilities.ScaleDPI(this);
     btnOK.Visible      = pnlColours.DisplayAdvanced;
     btnWindows.Visible = Globals.Root.User == Users.Editor;
 }
Exemple #3
0
        private void FillStylesList()
        {
            // fills in the drop-down list of standard styles
            bool old = m_Filling;

            m_Filling = true;
            m_Shared.Clear();
            cmbStyle.Items.Clear();
            // lnkDefaultStyle_LinkClicked relies on the default being the first item, and in this order
            m_Shared.Add(ButtonStyle.UserDefaultActionInstance);
            m_Shared.Add(ButtonStyle.UserDefaultSelectionInstance);
            foreach (ButtonStyle shared in Globals.Root.CurrentDocument.SharedButtonStyles())
            {
                Debug.Assert(shared.IsShared);
                m_Shared.Add(shared);
            }
            m_Shared.Sort();             // default is name order
            foreach (ButtonStyle style in m_Shared)
            {
                cmbStyle.Items.Add(Strings.Translate(style.Name));
                if (style == m_Style)
                {
                    // don't want to use IndexOf to find it later, as that uses the Equals method - want reference equals here - need to find the actual object, not a matching one
                    cmbStyle.SelectedIndex = cmbStyle.Items.Count - 1;
                }
            }
            if (!m_Style.IsShared)
            {
                Debug.Assert(!m_Shared.Contains(m_Style));
                m_Shared.Insert(0, m_Style);                 // Add(m_Style)	'
                cmbStyle.Items.Insert(0, Strings.Item("Button_CustomName"));
                cmbStyle.SelectedIndex = 0;
            }
            m_Filling = old;
        }
Exemple #4
0
        public cfgStyles()
        {
            InitializeComponent();
            Strings.Translate(this);

            pnlOutputNormal.Tag        = new Preview(SAW.Item.ItemDisplayTypes.IDT_Output, ButtonShape.States.Normal);
            pnlOutputHigh.Tag          = new Preview(SAW.Item.ItemDisplayTypes.IDT_Output, ButtonShape.States.Highlight);
            pnlGroupNormal.Tag         = new Preview(SAW.Item.ItemDisplayTypes.IDT_Group, ButtonShape.States.Normal);
            pnlGroupHigh.Tag           = new Preview(SAW.Item.ItemDisplayTypes.IDT_Group, ButtonShape.States.Highlight);
            pnlEscapeNormal.Tag        = new Preview(SAW.Item.ItemDisplayTypes.IDT_Escape, ButtonShape.States.Normal);
            pnlEscapeHighlight.Tag     = new Preview(SAW.Item.ItemDisplayTypes.IDT_Escape, ButtonShape.States.Highlight);
            pnlHelpNormal.Tag          = new Preview(SAW.Item.ItemDisplayTypes.IDT_Help, ButtonShape.States.Normal);
            pnlHelpHighlight.Tag       = new Preview(SAW.Item.ItemDisplayTypes.IDT_Help, ButtonShape.States.Highlight);
            pnlNotScannedNormal.Tag    = new Preview(SAW.Item.ItemDisplayTypes.IDT_NotScanned, ButtonShape.States.Normal);
            pnlNotScannedHighlight.Tag = new Preview(SAW.Item.ItemDisplayTypes.IDT_NotScanned, ButtonShape.States.Highlight);

            m_Previews = new[] { pnlOutputNormal, pnlOutputHigh, pnlGroupNormal, pnlGroupHigh, pnlEscapeNormal, pnlEscapeHighlight, pnlHelpNormal, pnlHelpHighlight, pnlNotScannedNormal, pnlNotScannedHighlight };
            foreach (Panel p in m_Previews)
            {
                p.Paint += PreviewPanel_Paint;
            }
            m_EditButtons = new[] { btnEditOutput, btnEditGroup, btnEditEscape, btnEditHelp, btnEditNotScanned };
            foreach (Button b in m_EditButtons)
            {
                b.Click += EditButton_Click;
            }
        }
Exemple #5
0
 public void frmCreateActivity_Load(object sender, EventArgs e)
 {
     Strings.Translate(this);
     GUIUtilities.ScaleDPI(this);             // no need to scale since the entire form is auto size
     m_AppliedUser    = Globals.Root.GenerateAppliedConfig(Users.User, Globals.Root.CurrentDocument);
     m_AppliedTeacher = Globals.Root.GenerateAppliedConfig(Users.Editor, Globals.Root.CurrentDocument);
 }
Exemple #6
0
        public static string GetActivityText(Guid activity, bool translate, bool display)
        {
            if (activity.Equals(Guid.Empty))
            {
                return(Strings.Item("Activity_Default"));
            }
            Document document = GetActivitySettings(activity);

            if (document != null)
            {
                string name = display ? document.DisplayName : document.Name;
                if (translate)
                {
                    name = Strings.Translate(name);
                }
                return(name);
            }
            // if we haven't got the activity, the name is often copied to documents using it, so check the current document
            if (Globals.Root.CurrentDocument != null && Globals.Root.CurrentDocument.ActivityID.Equals(activity))
            {
                string name = translate ? Globals.Root.CurrentDocument.DisplayName : Globals.Root.CurrentDocument.Name;
                if (!string.IsNullOrEmpty(name))
                {
                    if (translate)
                    {
                        return(Strings.Translate(name));
                    }
                    return(name);
                }
            }
            Utilities.LogSubError("GetActivityText: cannot locate name for " + activity + "\'");
            return("?");
        }
Exemple #7
0
        public void btnPaletteCreate_Click(object sender, EventArgs e)
        {
            string name        = "";
            string description = "";
            string subTitle    = "";

            Palette.Purpose purpose = Palette.Purpose.Custom;
            bool            isFlow  = true;

            if (frmPaletteDetails.Display(ref name, ref description, ref subTitle, ref purpose, ref isFlow, false) != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            string display = Strings.Translate(description) + (!string.IsNullOrEmpty(subTitle) ? " (" + Strings.Translate(subTitle) + ")" : "");

            if (m_DisplayedPalettes.Any(d => d.PaletteEditingFullDescription == display))
            {
                MessageBox.Show(Strings.Item("Palette_DescriptionDuplicate"));
                return;
            }
            Document document = new Document(false)
            {
                ActivityID         = Activities.PaletteID,
                PaletteWithin      = m_Config,
                PaletteTitle       = name,
                PaletteDescription = description,
                PalettePurpose     = purpose,
                SnapMode           = Shape.SnapModes.Grid,
                SubTitle           = subTitle
            };

            document.PaletteDesignSize = new SizeF(60, 30);
            document.Page(0).SetSize(document.PaletteDesignSize, 0);
            document.Page(0).Paper = Paper.CreateNew(Paper.Papers.Graph, document.Page(0).Paper);
            document.Page(0).Paper.SetIntervals(1, 1, 10);
            if (isFlow)
            {
                Flow flow = new Flow()
                {
                    Direction = Flow.Directions.RightThenDown, ShapeSeparation = 1
                };
                flow.LineStyle.SetDefaults();
                flow.FillStyle.SetDefaults();
                flow.LineStyle.Colour = Color.Empty;
                flow.FillStyle.Colour = System.Drawing.Color.Empty;
                flow.SetBounds(document.Page(0).Bounds);
                document.Page(0).AddNew(flow, null);
            }

            m_Config.CustomPalettes.Add(document);
            Palette registration = new Palette(document);

            if (document.PalettePurpose.IsCustom)             // ensure new custom one shown
            {
                m_Config.Write(Config.ShowPaletteKey(registration), true.ToString());
            }
            WrittenToCurrent();
            Palette.Register(registration);
            Form.CloseAndEditPalette(document);
        }
Exemple #8
0
 public frmActivityRename(Document activity)
 {
     InitializeComponent();
     m_Activity = activity;
     Strings.Translate(this);             // must be before the text boxes are assigned
     txtDisplayName.Text = activity.DisplayName;
     txtName.Text        = activity.Name;
 }
Exemple #9
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();
        }
Exemple #10
0
 public Operation(string name)
 {
     Name = Strings.Translate(name);
     if (CurrentOperation != null)
     {
         throw new Exception("Overlapping operations not permitted");
     }
     CurrentOperation = this;
     OperationErrors.Clear();
 }
Exemple #11
0
 public void frmUpdate_Load(object sender, EventArgs e)
 {
     Strings.Translate(this);
     GUIUtilities.ScaleDPI(this);
     txtCurrent.Text = SoftwareVersion.VersionString;
     Folder          = Globals.Root.SharedFolder + System.IO.Path.DirectorySeparatorChar + "Update";
     if (!System.IO.Directory.Exists(Folder))
     {
         System.IO.Directory.CreateDirectory(Folder);
     }
     Folder += System.IO.Path.DirectorySeparatorChar;
 }
Exemple #12
0
        private void tmrRefill_Tick(object sender, EventArgs e)
        {
            tmrRefill.Enabled = false;
            tableMain.SuspendLayout();
            m_Filling = true;
            List <Shape> selection = Globals.Root.CurrentPage?.SelectedShapes;

            if (selection == null || selection.Count != 1)
            {
                lblSelect.Visible = true;
                foreach (IntegerTextBox txt in m_X.Union(m_Y))
                {
                    txt.Enabled = false;
                }
            }
            else
            {
                lblSelect.Visible = false;
                Shape    shape             = selection.First();
                Target   m_DisplayedTarget = Globals.Root.CurrentPage.SelectedPath;               // item within the current shape (can be null)
                string[] names;
                (m_GrabSpots, names) = shape.GetEditableCoords(m_DisplayedTarget);
                for (int i = 0; i <= 3; i++)
                {
                    m_Labels[i].Visible = m_X[i].Visible = m_Y[i].Visible = i < names.Length;
                    if (i < names.Length)
                    {
                        m_Labels[i].Text = Strings.Translate(names[i]);
                        switch (m_GrabSpots[i].GrabType)
                        {
                        case Shape.GrabTypes.EdgeMoveH:
                            m_X[i].Value   = (int)Math.Abs(m_GrabSpots[i].Position.X - m_GrabSpots[i].Focus.X);
                            m_Y[i].Visible = false;
                            break;

                        case Shape.GrabTypes.EdgeMoveV:
                            m_X[i].Value   = (int)Math.Abs(m_GrabSpots[i].Position.Y - m_GrabSpots[i].Focus.Y);
                            m_Y[i].Visible = false;
                            break;

                        default:
                            m_X[i].Value   = (int)m_GrabSpots[i].Position.X;
                            m_Y[i].Value   = -(int)m_GrabSpots[i].Position.Y;
                            m_Y[i].Visible = true;
                            break;
                        }
                        m_X[i].Enabled = m_Y[i].Enabled = true;
                    }
                }
            }
            m_Filling = false;
            tableMain.ResumeLayout();
        }
Exemple #13
0
 public frmGridWizard()
 {
     InitializeComponent();
     Strings.Translate(this);
     m_Panels = new[] { tblLayout, tblOrder, tblEscape };
     tblOrder.SetBounds(tblLayout.Left, tblLayout.Top, tblLayout.Width, tblLayout.Height);
     tblEscape.SetBounds(tblLayout.Left, tblLayout.Top, tblLayout.Width, tblLayout.Height);
     tblOrder.Bounds              = tblLayout.Bounds;
     tblEscape.Bounds             = tblLayout.Bounds;
     cmbEscapeRatio.SelectedIndex = 2;
     cmbEscapes.SelectedIndex     = 2;
     UpdateButtons();
 }
Exemple #14
0
        private frmEditDesktop(Desktop desktopToEdit)
        {
            InitializeComponent();
            Strings.Translate(this);

            m_Desktop = desktopToEdit;
            foreach (Desktop.Program p in m_Desktop.Programs)
            {
                var create = lstPrograms.Items.Add(p.Name);
                create.SubItems.Add(p.Path);
                create.Tag = p;
            }
        }
Exemple #15
0
 /// <summary>To be called for any page which appears here.  For convenience returns the same object</summary>
 private ConfigPage AddPanel(ConfigPage pnl)
 {
     Strings.Translate(pnl, ttMain);
     pnl.Form = this;
     Controls.Add(pnl);
     pnl.Visible = false;
     pnl.Dock    = DockStyle.Fill;
     pnl.BringToFront();
     if (pnl.Controls.Count == 1)
     {
         pnl.Controls[0].Visible = true;                 // because they were designed with Visible = false when the panels were directly on this page
     }
     return(pnl);
 }
Exemple #16
0
        private readonly Document m_Document;         // document being edited

        public frmTexture(DatumList systemTextures, Document document)
        {
            InitializeComponent();
            m_Document = document;
            Strings.Translate(this);
            FillList(lstSystem, systemTextures);
            // can't just use document.SharedBitmapsList because that is all sorts of imported images
            DatumList colUsed = document.TexturesUsed();

            FillList(lstDocument, colUsed);
            if (colUsed.Count == 0)
            {
                tpDocument.Dispose();
            }
        }
Exemple #17
0
        /// <summary>returns "" if cancelled</summary>
        public static string ShowOpen(Context context, string filter = "", string overrideFolder = "")
        {
            // If this is on Windows it will automatically use the version with the preview panel if the context is document
            if (string.IsNullOrEmpty(filter))
            {
                filter = GetDefaultFilter(context);
            }
            string key      = OpenConfigKey(context);
            string existing = Globals.Root.CurrentConfig.ReadString(key);

            if (string.IsNullOrEmpty(existing))
            {
                existing = Globals.Root.CurrentConfig.ReadString(SaveConfigKey(context));                 // if the user has not opened, use any save folder
            }
            if (!System.IO.Directory.Exists(existing))
            {
                existing = "";
            }
            if (!string.IsNullOrEmpty(overrideFolder))
            {
                existing = overrideFolder;
            }
            Debug.Assert(context != Context.Document || string.IsNullOrEmpty(filter) || filter == Document.LoadFilter(),
                         "Specifying a filter with Document context in FileDialog.ShowOpen will fail as it uses the preview dialog which assumes the document filter");
            if (context == Context.Document)
            {
                return(ShowOpenWithDocumentPreview(filter, key));
            }
            if (g_dlgOpen == null)
            {
                g_dlgOpen = new OpenFileDialog();
            }
            else
            {
                g_dlgOpen.FileName = "";
            }
            if (!string.IsNullOrEmpty(existing))
            {
                g_dlgOpen.InitialDirectory = existing;
            }
            g_dlgOpen.Filter = Strings.Translate(filter);
            if (g_dlgOpen.ShowDialog() != DialogResult.OK)
            {
                return(null);
            }
            Config.SystemConfig.Write(key, System.IO.Path.GetDirectoryName(g_dlgOpen.FileName));
            return(g_dlgOpen.FileName);
        }
Exemple #18
0
        private float m_OriginalAR;         // actually we should use the AR of the image to avoid cumulative rounding errors, but I don't think it will make a noticeable difference

        private frmEditBounds(Rectangle rct, bool lockAR = false)
        {
            InitializeComponent();
            Strings.Translate(this);
            Value                     = rct;
            m_OriginalValue           = rct;
            m_ARLocked                = lockAR;
            Owner                     = Globals.Root.Editor;
            chkAdjustContents.Enabled = !lockAR;
            txtHeight.Enabled         = !lockAR;
            if (lockAR)
            {
                chkAdjustContents.Checked = true;
            }
            lblARlocked.Visible = lockAR;
            m_OriginalAR        = (float)Math.Max(rct.Width, 1) / Math.Max(rct.Height, 1);      // the .Max avoid any awkward zeroes or infinities which could throw exceptions
        }
Exemple #19
0
 public Palette(string customID, Purpose purpose, Control ctr, string title, string imageName)
 {
     Debug.Assert(ctr is IPalette);
     m_CustomID      = customID;
     Control         = ctr;
     Title           = Strings.Translate(title);
     EditDescription = Title + " " + Strings.Item("Palette_DefaultSuffix");
     if (Strings.IsTranslationMode)
     {
         Title = "(" + ctr.GetType() + ") " + Title;
     }
     if (!string.IsNullOrEmpty(imageName))
     {
         Icon = (Bitmap)GUIUtilities.RM.GetObject(imageName);
     }
     PalettePurpose = purpose;
 }
Exemple #20
0
 public Palette(Parameters parameter, Control ctr, string title, string imageName)
 {
     Debug.Assert(ctr is IPalette);
     Control          = ctr;
     PaletteParameter = parameter;
     Title            = Strings.Translate(title);
     if (Strings.IsTranslationMode)
     {
         Title = "(" + ctr.GetType() + ") " + Title;
     }
     EditDescription = Title + " " + Strings.Item("Palette_DefaultSuffix");
     if (!string.IsNullOrEmpty(imageName))
     {
         Icon = (Bitmap)GUIUtilities.RM.GetObject(imageName);
     }
     PalettePurpose = new Purpose(parameter);
 }
Exemple #21
0
        public cfgSwitching()
        {
            PhysicalSwitch.Initialise();             // will be ignored if already done.  Required for detect mechanism to work

            InitializeComponent();
            Strings.Translate(this);
            TimingLabels   = new[] { lblAcceptance, lblPostActivation, lblLongPress, lblScanTime, lblFirstRepeat, lblSubsequentRepeat, lblDwellSelect, lblCriticalReverse };
            TimingControls = new[] { ctrTimingAcceptance, ctrTimingPostActivation, ctrTimingLongPress, ctrTimingScanTime, ctrTimingFirstRepeat, ctrTimingSubsequentRepeat, ctrTimingDwellTime, ctrTimingCriticalReverse };
            foreach (Label lbl in TimingLabels)
            {
                Engine.Timings timing = (Engine.Timings)Convert.ToInt32(lbl.Tag);
                lbl.Text = Strings.Item("Switch_Timing_" + timing);
            }
            foreach (ctrEditTiming ctr in TimingControls)
            {
                ctr.UserChangedValue += ctrTiming_UserChangedValue;
            }
        }
Exemple #22
0
        public Button AddWithImage(string text, Bitmap image)
        {
            // This needs to use a button in order to get the text image relationship.  With a label both are superimposed
            Button button = new Button {
                Text = Strings.Translate(text), Padding = new Padding(2), FlatStyle = FlatStyle.Flat
            };

            button.FlatAppearance.BorderSize = 0;
            button.Image             = image;
            button.ImageAlign        = ContentAlignment.MiddleLeft;
            button.TextImageRelation = TextImageRelation.ImageBeforeText;
            button.Margin            = new Padding(1, 1, 1, 2);
            button.AutoSize          = true;
            UpdateButtonColours(button);
            button.AutoEllipsis = true;
            this.Controls.Add(button);
            return(button);
        }
Exemple #23
0
 public ctrActionSelect()
 {
     ActionImageList = new ImageList()
     {
         ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(32, 32), TransparentColor = Color.Transparent
     };
     InitializeComponent();
     TV.HideSelection = false;
     if (!this.DesignMode)
     {
         lblSearch.Text = Strings.Item("Search");
     }
     Strings.Translate(this, ttActions);
     if (!this.DesignMode)
     {
         TV.ImageList = ActionImageList;
     }
 }
Exemple #24
0
        public void frmFont_Load(object sender, EventArgs e)
        {
            // this assumes the form will only be used once before being disposed
            m_Filling = true;
            try
            {
                if (SelectedFont == null)
                {
                    SelectedFont = new Font(FontFamily.GenericSansSerif, 10);
                }
                chkBold.Checked      = (SelectedFont.Style & FontStyle.Bold) > 0;
                chkItalic.Checked    = (SelectedFont.Style & FontStyle.Italic) > 0;
                chkStrikeout.Checked = (SelectedFont.Style & FontStyle.Strikeout) > 0;
                chkUnderline.Checked = (SelectedFont.Style & FontStyle.Underline) > 0;

                // size box... first fill in the values
                float size = 6f;
                while (size < MAXIMUMFONTSIZE)
                {
                    cmbSize.Items.Add(size.ToString("0"));
                    size = AdjustSize(size, +1);
                }
                cmbSize.Items.Add(size.ToString("0"));                 // add the final one, MAXIMUMFONTSIZE
                cmbSize.Text = SelectedFont.Size.ToString("0.#");

                Strings.Translate(this);
                GUIUtilities.ScaleDPI(this);
                int selected = IndexOfFontFace(SelectedFont.Name);
                for (int index = 0; index <= g_Names.Count - 1; index++)
                {
                    lstFont.Items.Add(g_Names[index]);
                }
                if (selected >= 0)
                {
                    lstFont.SelectedIndex = selected;
                }
            }
            finally
            {
                m_Filling = false;
            }
        }
Exemple #25
0
        // support for reporting non-fatal errors in large operations.  Not implemented yet

        /// <summary>Reports an error which may be non-fatal in some cases</summary>
        /// <param name="text">Translatable text</param>
        /// <param name="throwOutsideOperation">If true this throws an exception if not in a context where a group of non-fatal errors can be reported</param>
        public static void NonFatalOperationalError(string text, bool throwOutsideOperation = true)
        {
            text = Strings.Translate(text);
            Root.Log.WriteLine("Op error: " + text);
            if (CurrentOperation != null)
            {
                if (OperationErrors.ContainsKey(text))
                {
                    OperationErrors[text] += 1;
                }
                else
                {
                    OperationErrors.Add(text, 1);
                }
            }
            else if (throwOutsideOperation)
            {
                throw new UserException(text);
            }
        }
Exemple #26
0
        private const int MAXCACHE  = 20 * 1000 * 1000;       // 20mb (ish)

        private frmOpenSymbol(string text)
        {
            InitializeComponent();
            Strings.Translate(this);
            txtText.Text = text;
            DoSearch();

            if (g_CacheFolder == null)
            {
                g_CacheFolder = Path.Combine(Globals.Root.SharedFolder, "OpenSymbolCache");
            }
            if (!Directory.Exists(g_CacheFolder))
            {
                Directory.CreateDirectory(g_CacheFolder);
            }
            EnsureCacheList();

            txtText.GotFocus += (s, e) => AcceptButton = btnSearch;
            Activated        += (s, e) => txtText.Focus();
        }
Exemple #27
0
        public Palette(Document document)
        {
            // version for user-defined palette
            m_CustomID     = document.ID.ToString();
            CustomDocument = document;
            Control        = new PaletteView(document, this);

            Title = Strings.Translate(document.PaletteTitle);
            if (Strings.IsTranslationMode)
            {
                Title = "{" + document.ID + "} " + Title;
            }
            EditDescription = Strings.Translate(document.PaletteEditingFullDescription);
            PalettePurpose  = document.PalettePurpose;
            string imageName = PalettePurpose.ImageName;

            if (!string.IsNullOrEmpty(imageName))
            {
                Icon = (Bitmap)GUIUtilities.RM.GetObject(imageName);
            }
        }
Exemple #28
0
        private void pnlPreview_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            Rectangle rctPreview = new Rectangle(0, 0, Width, Height);

            if (this.DesignMode)
            {
                e.Graphics.DrawString("Preview goes here", Font, Brushes.DarkGray, rctPreview, GUIUtilities.StringFormatCentreCentre);
            }
            else
            {
                if (m_img == null)
                {
                    e.Graphics.DrawString(Strings.Translate(NoImageString), Font, Brushes.DarkGray, rctPreview, GUIUtilities.StringFormatCentreCentre);
                }
                else
                {
                    GUIUtilities.CalcDestRect(m_img.Width, m_img.Height, ref rctPreview);
                    e.Graphics.DrawImage(m_img, rctPreview);
                }
            }
        }
Exemple #29
0
 public static string ConfigKeyDescription(string key, Config config)
 {
     if (key.StartsWith("Key_"))
     {
         return(GUIUtilities.KeyDescription((Keys)Convert.ToInt32(key.Substring(4), 16)));
         // add ElseIf as necessary
     }
     else if (key.StartsWith("Show_Palette_"))
     {
         string paletteKey = key.Replace("Show_Palette_", "");
         if (Palette.List.ContainsKey(paletteKey))
         {
             return(Strings.Translate(Palette.List[paletteKey].EditDescription));
         }
         else
         {
             return("Palette not found");
         }
     }
     return("");
 }
Exemple #30
0
        private frmPaletteDetails()
        {
            InitializeComponent();
            Strings.Translate(this);             // Must be before the values are assigned

            List <Palette.Purpose> list = new List <Palette.Purpose>();

            // we filter out a few purposes which aren't appropriate for user defined palettes
            foreach (Palette.Purpose purpose in Palette.Purpose.PossiblePurposes)
            {
                switch (purpose.Special)
                {
                case Palette.Purpose.Specials.Sockets:
                default:
                    list.Add(purpose);
                    break;
                }
            }
            cmbPurpose.DataSource    = list;
            cmbPurpose.ValueMember   = "Parameter";           // or "Special" - they are interchangeable
            cmbPurpose.DisplayMember = "Name";
        }