Beispiel #1
0
        private void ChangeLineColor(object sender, System.EventArgs e)
        {
            var location = PointToScreen(colorBox.Location);

            using (var dialog = new UI.MoreColorDialog(Resx.PageColorDialog_Text,
                                                       location.X + colorBox.Bounds.Location.X + (colorBox.Width / 2),
                                                       location.Y - 50))
            {
                dialog.Color = colorBox.BackColor;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    colorBox.BackColor = dialog.Color;
                }
            }
        }
Beispiel #2
0
        public override async Task Execute(params object[] args)
        {
            if (!Native.GetCursorPos(out var location))
            {
                location = new Native.Point()
                {
                    X = 100, Y = 100
                };
            }

            // adjust for offset of context menu item that invokes this command
            location.Y -= SystemInformation.MenuHeight * 4;
            location.X -= 30;

            using (var one = new OneNote())
            {
                var section      = one.GetSection();
                var sectionColor = section.Attribute("color").Value;
                if (sectionColor == "none")
                {
                    // close approximation of none
                    sectionColor = "#F0F0F0";
                }

                using (var dialog = new UI.MoreColorDialog(
                           Resx.SectionColor_Title, location.X, location.Y))
                {
                    dialog.Color    = ColorTranslator.FromHtml(sectionColor);
                    dialog.FullOpen = true;

                    // use the elevator to force ColorDialog to top-most first time used
                    // otherwise, it will be hidden by the OneMore window
                    using (var elevator = new UI.WindowElevator(dialog))
                    {
                        var result = elevator.ShowDialog(owner);
                        if (result == DialogResult.OK)
                        {
                            section.SetAttributeValue("color", dialog.Color.ToRGBHtml());
                            one.UpdateHierarchy(section);
                        }
                    }
                }
            }

            await Task.Yield();
        }
Beispiel #3
0
        private Color SelectColor(string title, Rectangle bounds, Color color)
        {
            var location = PointToScreen(toolStrip.Location);

            using (var dialog = new UI.MoreColorDialog(title,
                                                       location.X + bounds.Location.X,
                                                       location.Y + bounds.Height + 4))
            {
                dialog.Color = color;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    return(dialog.Color);
                }
            }

            return(Color.Empty);
        }
        private void ChooseCustomColor(object sender, EventArgs e)
        {
            if (initialized && customButton.Checked)
            {
                var location = PointToScreen(customButton.Location);

                using (var dialog = new UI.MoreColorDialog(Resx.PageColorDialog_Text,
                                                           location.X + customButton.Bounds.Location.X + (customButton.Width / 2),
                                                           location.Y - 200))
                {
                    dialog.Color = pageColor;

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        SetCustomOption(dialog.Color);
                    }
                }
            }
        }
Beispiel #5
0
        private void ChooseCustomColor(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var location = PointToScreen(customLink.Location);

            using (var dialog = new UI.MoreColorDialog(Resx.PageColorDialog_Text,
                                                       location.X + customLink.Bounds.Location.X + customLink.Width,
                                                       location.Y - 50))
            {
                dialog.Color = colorsBox.CustomColor;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    colorsBox.SetCustomColor(dialog.Color);

                    var provider = new SettingsProvider();
                    var settings = provider.GetCollection("pageTheme");
                    settings.Add("customColor", dialog.Color.ToRGBHtml());
                    provider.SetCollection(settings);
                    provider.Save();
                }
            }
        }