Exemple #1
0
        public static void ShowColourEditorForm(string message)
        {
            string effectname = message.Substring(0, message.IndexOf(" ", StringComparison.Ordinal));
            string text = message.Substring(message.IndexOf(" ", StringComparison.Ordinal) + 1);
            ButtonEffect effect = (ButtonEffect)Enum.Parse(typeof(ButtonEffect), effectname);

            ColourEditor newForm;

            if (editorForms.ContainsKey(effect))
            {
                if (editorForms.TryGetValue(effect, out newForm))
                {
                    newForm.BringToFront();
                    return;
                }
            }

            newForm = new ColourEditor(effect, text);

            PositionColourEditorForm(newForm);

            editorForms.Add(effect, newForm);
            newForm.FormClosed += ChildFormClosed;
            newForm.Show(_mainForm);

        }
Exemple #2
0
        private static Point GetColourEditorFormStartingPosition(ColourEditor ce)
        {
            if (_colourMapForm != null)
            {
                // Start from top right of colour map
                return GetNewLocation(_colourMapForm, ce, ChildFormPosition.TopRight);
            }

            return GetNewLocation(_mainForm, ChildFormPosition.BottomLeft);  // Risque as isn't a child, but will work.
        }
Exemple #3
0
        private static void PositionColourEditorForm(ColourEditor ce)
        {
            // Now, where to put it..

            // TODO - Why is this value not being used?
            Point formLocation = GetColourEditorFormStartingPosition(ce);

            // If there are no other forms use the last closed position (if there is one)
            // (current form must be new and hasn't been added to collection yet)
            if (editorForms.Count == 0)
            {

                Properties.Settings userSettings = new Properties.Settings();
                Point savedLocation = userSettings.ColourEditorLocation;
                if (savedLocation == Point.Empty)
                {
                    // Colour Map form must be open as we must be spawning a new editor (as the count is zero)
                    formLocation = GetNewLocation(_colourMapForm, ce, ChildFormPosition.TopRight);
                }
                else
                {
                    formLocation = savedLocation;
                }
            }
            else
            {
                // There are 1-many forms open. They could be all over the screen:
                // pick the bottommost rightmost one and cascade off it
                // (Using top left means having to find the topleftmost form
                // that isn't cascaded,

                Point p = new Point(-5000, -5000);

                foreach (ColourEditor openform in editorForms.Values)
                {
                    if (openform == null || openform == ce)
                        continue;

                    if (openform.Location.X > p.X && openform.Location.Y > p.Y)
                        p = openform.Location;
                }

                formLocation = new Point(p.X + 10, p.Y + SystemInformation.CaptionHeight + 5);

            }

            ce.Location = formLocation;
        }