示例#1
0
        public override void HandleBuildToolBar(Gtk.Toolbar tb, ISettingsService settings, string toolPrefix)
        {
            base.HandleBuildToolBar(tb, settings, toolPrefix);


            if (radius_sep == null)
            {
                radius_sep = new Gtk.SeparatorToolItem();
            }

            tb.AppendItem(radius_sep);

            if (radius_label == null)
            {
                radius_label = new ToolBarLabel(string.Format("  {0}: ", Translations.GetString("Radius")));
            }

            tb.AppendItem(radius_label);

            if (radius == null)
            {
                radius = new (new Gtk.SpinButton(0, 1e5, 1)
                {
                    Value = settings.GetSetting(RADIUS_SETTING(toolPrefix), 20)
                });

                radius.Widget.ValueChanged += (o, e) => {
                    //Go through the Get/Set routine.
                    Radius = Radius;
                };
            }

            tb.AppendItem(radius);
        }
示例#2
0
        public override void HandleBuildToolBar(Gtk.Toolbar tb)
        {
            base.HandleBuildToolBar(tb);


            if (radius_sep == null)
            {
                radius_sep = new Gtk.SeparatorToolItem();
            }

            tb.AppendItem(radius_sep);

            if (radius_label == null)
            {
                radius_label = new ToolBarLabel(string.Format("  {0}: ", Catalog.GetString("Radius")));
            }

            tb.AppendItem(radius_label);

            if (radius_minus == null)
            {
                radius_minus          = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease shape's corner radius"));
                radius_minus.Clicked += RadiusMinusButtonClickedEvent;
            }

            tb.AppendItem(radius_minus);

            if (radius == null)
            {
                radius = new ToolBarComboBox(65, 16, true, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                                             "10", "11", "12", "13", "14", "15", "20", "25", "30", "40",
                                             "50", "60", "70", "80");

                radius.ComboBox.Changed += (o, e) =>
                {
                    //Go through the Get/Set routine.
                    Radius = Radius;
                };
            }

            tb.AppendItem(radius);

            if (radius_plus == null)
            {
                radius_plus          = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase shape's corner radius"));
                radius_plus.Clicked += RadiusPlusButtonClickedEvent;
            }

            tb.AppendItem(radius_plus);
        }
示例#3
0
        protected override void BuildToolBar(Gtk.Toolbar tb)
        {
            base.BuildToolBar(tb);

            if (radius_sep == null)
            {
                radius_sep = new Gtk.SeparatorToolItem();
            }

            tb.AppendItem(radius_sep);

            if (radius_label == null)
            {
                radius_label = new ToolBarLabel(string.Format("  {0}: ", Catalog.GetString("Radius")));
            }

            tb.AppendItem(radius_label);

            if (radius_minus == null)
            {
                radius_minus          = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease rectangle's corner radius"));
                radius_minus.Clicked += RadiusMinusButtonClickedEvent;
            }

            tb.AppendItem(radius_minus);

            if (radius == null)
            {
                radius = new ToolBarComboBox(65, 2, true, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                                             "10", "11", "12", "13", "14", "15", "20", "25", "30", "35",
                                             "40", "45", "50", "55");
            }

            tb.AppendItem(radius);

            if (radius_plus == null)
            {
                radius_plus          = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase rectangle's corner radius"));
                radius_plus.Clicked += RadiusPlusButtonClickedEvent;
            }

            tb.AppendItem(radius_plus);
        }
示例#4
0
        public override void HandleBuildToolBar(Gtk.Toolbar tb)
        {
            base.HandleBuildToolBar(tb);


            #region Show Arrows

            //Arrow separator.

            if (arrowSep == null)
            {
                arrowSep = new Gtk.SeparatorToolItem();

                showOtherArrowOptions = false;
            }

            tb.AppendItem(arrowSep);


            if (arrowLabel == null)
            {
                arrowLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Arrow")));
            }

            tb.AppendItem(arrowLabel);


            //Show arrow 1.

            showArrowOneBox        = new Gtk.CheckButton("1");
            showArrowOneBox.Active = previousSettings1.Show;

            showArrowOneBox.Toggled += (o, e) =>
            {
                //Determine whether to change the visibility of Arrow options in the toolbar based on the updated Arrow showing/hiding.
                if (!showArrowOneBox.Active && !showArrowTwoBox.Active)
                {
                    if (showOtherArrowOptions)
                    {
                        tb.Remove(arrowSizeLabel);
                        tb.Remove(arrowSizeMinus);
                        tb.Remove(arrowSize);
                        tb.Remove(arrowSizePlus);
                        tb.Remove(arrowAngleOffsetLabel);
                        tb.Remove(arrowAngleOffsetMinus);
                        tb.Remove(arrowAngleOffset);
                        tb.Remove(arrowAngleOffsetPlus);
                        tb.Remove(arrowLengthOffsetLabel);
                        tb.Remove(arrowLengthOffsetMinus);
                        tb.Remove(arrowLengthOffset);
                        tb.Remove(arrowLengthOffsetPlus);

                        showOtherArrowOptions = false;
                    }
                }
                else
                {
                    if (!showOtherArrowOptions)
                    {
                        tb.Add(arrowSizeLabel);
                        tb.Add(arrowSizeMinus);
                        tb.Add(arrowSize);
                        tb.Add(arrowSizePlus);
                        tb.Add(arrowAngleOffsetLabel);
                        tb.Add(arrowAngleOffsetMinus);
                        tb.Add(arrowAngleOffset);
                        tb.Add(arrowAngleOffsetPlus);
                        tb.Add(arrowLengthOffsetLabel);
                        tb.Add(arrowLengthOffsetMinus);
                        tb.Add(arrowLengthOffset);
                        tb.Add(arrowLengthOffsetPlus);

                        showOtherArrowOptions = true;
                    }
                }

                LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

                if (activeEngine != null)
                {
                    activeEngine.Arrow1.Show = showArrowOneBox.Active;

                    DrawActiveShape(false, false, true, false, false);

                    storePreviousSettings();
                }
            };

            tb.AddWidgetItem(showArrowOneBox);


            //Show arrow 2.

            showArrowTwoBox        = new Gtk.CheckButton("2");
            showArrowTwoBox.Active = previousSettings2.Show;

            showArrowTwoBox.Toggled += (o, e) =>
            {
                //Determine whether to change the visibility of Arrow options in the toolbar based on the updated Arrow showing/hiding.
                if (!showArrowOneBox.Active && !showArrowTwoBox.Active)
                {
                    if (showOtherArrowOptions)
                    {
                        tb.Remove(arrowSizeLabel);
                        tb.Remove(arrowSizeMinus);
                        tb.Remove(arrowSize);
                        tb.Remove(arrowSizePlus);
                        tb.Remove(arrowAngleOffsetLabel);
                        tb.Remove(arrowAngleOffsetMinus);
                        tb.Remove(arrowAngleOffset);
                        tb.Remove(arrowAngleOffsetPlus);
                        tb.Remove(arrowLengthOffsetLabel);
                        tb.Remove(arrowLengthOffsetMinus);
                        tb.Remove(arrowLengthOffset);
                        tb.Remove(arrowLengthOffsetPlus);

                        showOtherArrowOptions = false;
                    }
                }
                else
                {
                    if (!showOtherArrowOptions)
                    {
                        tb.Add(arrowSizeLabel);
                        tb.Add(arrowSizeMinus);
                        tb.Add(arrowSize);
                        tb.Add(arrowSizePlus);
                        tb.Add(arrowAngleOffsetLabel);
                        tb.Add(arrowAngleOffsetMinus);
                        tb.Add(arrowAngleOffset);
                        tb.Add(arrowAngleOffsetPlus);
                        tb.Add(arrowLengthOffsetLabel);
                        tb.Add(arrowLengthOffsetMinus);
                        tb.Add(arrowLengthOffset);
                        tb.Add(arrowLengthOffsetPlus);

                        showOtherArrowOptions = true;
                    }
                }

                LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

                if (activeEngine != null)
                {
                    activeEngine.Arrow2.Show = showArrowTwoBox.Active;

                    DrawActiveShape(false, false, true, false, false);

                    storePreviousSettings();
                }
            };

            tb.AddWidgetItem(showArrowTwoBox);

            #endregion Show Arrows


            #region Arrow Size

            if (arrowSizeLabel == null)
            {
                arrowSizeLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Size")));
            }

            if (arrowSizeMinus == null)
            {
                arrowSizeMinus          = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease arrow size"));
                arrowSizeMinus.Clicked += new EventHandler(arrowSizeMinus_Clicked);
            }

            if (arrowSize == null)
            {
                arrowSize = new ToolBarComboBox(65, 7, true,
                                                "3", "4", "5", "6", "7", "8", "9", "10", "12", "15", "18",
                                                "20", "25", "30", "40", "50", "60", "70", "80", "90", "100");

                arrowSize.ComboBox.Changed += (o, e) =>
                {
                    if (arrowSize.ComboBox.ActiveText.Length < 1)
                    {
                        //Ignore the change until the user enters something.
                        return;
                    }
                    else
                    {
                        double newSize = 10d;

                        if (arrowSize.ComboBox.ActiveText == "-")
                        {
                            //The user is trying to enter a negative value: change it to 1.
                            newSize = 1d;
                        }
                        else
                        {
                            if (Double.TryParse(arrowSize.ComboBox.ActiveText, out newSize))
                            {
                                if (newSize < 1d)
                                {
                                    //Less than 1: change it to 1.
                                    newSize = 1d;
                                }
                                else if (newSize > 100d)
                                {
                                    //Greater than 100: change it to 100.
                                    newSize = 100d;
                                }
                            }
                            else
                            {
                                //Not a number: wait until the user enters something.
                                return;
                            }
                        }

                        (arrowSize.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newSize.ToString();

                        LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

                        if (activeEngine != null)
                        {
                            activeEngine.Arrow1.ArrowSize = newSize;
                            activeEngine.Arrow2.ArrowSize = newSize;

                            DrawActiveShape(false, false, true, false, false);

                            storePreviousSettings();
                        }
                    }
                };
            }

            if (arrowSizePlus == null)
            {
                arrowSizePlus          = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase arrow size"));
                arrowSizePlus.Clicked += new EventHandler(arrowSizePlus_Clicked);
            }

            #endregion Arrow Size


            #region Angle Offset

            if (arrowAngleOffsetLabel == null)
            {
                arrowAngleOffsetLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Angle")));
            }

            if (arrowAngleOffsetMinus == null)
            {
                arrowAngleOffsetMinus          = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease angle offset"));
                arrowAngleOffsetMinus.Clicked += new EventHandler(arrowAngleOffsetMinus_Clicked);
            }

            if (arrowAngleOffset == null)
            {
                arrowAngleOffset = new ToolBarComboBox(65, 9, true,
                                                       "-30", "-25", "-20", "-15", "-10", "-5", "0", "5", "10", "15", "20", "25", "30");

                arrowAngleOffset.ComboBox.Changed += (o, e) =>
                {
                    if (arrowAngleOffset.ComboBox.ActiveText.Length < 1)
                    {
                        //Ignore the change until the user enters something.
                        return;
                    }
                    else if (arrowAngleOffset.ComboBox.ActiveText == "-")
                    {
                        //The user is trying to enter a negative value: ignore the change until the user enters more.
                        return;
                    }
                    else
                    {
                        double newAngle = 15d;

                        if (Double.TryParse(arrowAngleOffset.ComboBox.ActiveText, out newAngle))
                        {
                            if (newAngle < -89d)
                            {
                                //Less than -89: change it to -89.
                                newAngle = -89d;
                            }
                            else if (newAngle > 89d)
                            {
                                //Greater than 89: change it to 89.
                                newAngle = 89d;
                            }
                        }
                        else
                        {
                            //Not a number: wait until the user enters something.
                            return;
                        }

                        (arrowAngleOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newAngle.ToString();

                        LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

                        if (activeEngine != null)
                        {
                            activeEngine.Arrow1.AngleOffset = newAngle;
                            activeEngine.Arrow2.AngleOffset = newAngle;

                            DrawActiveShape(false, false, true, false, false);

                            storePreviousSettings();
                        }
                    }
                };
            }

            if (arrowAngleOffsetPlus == null)
            {
                arrowAngleOffsetPlus          = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase angle offset"));
                arrowAngleOffsetPlus.Clicked += new EventHandler(arrowAngleOffsetPlus_Clicked);
            }

            #endregion Angle Offset


            #region Length Offset

            if (arrowLengthOffsetLabel == null)
            {
                arrowLengthOffsetLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Length")));
            }

            if (arrowLengthOffsetMinus == null)
            {
                arrowLengthOffsetMinus          = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease length offset"));
                arrowLengthOffsetMinus.Clicked += new EventHandler(arrowLengthOffsetMinus_Clicked);
            }

            if (arrowLengthOffset == null)
            {
                arrowLengthOffset = new ToolBarComboBox(65, 8, true,
                                                        "-30", "-25", "-20", "-15", "-10", "-5", "0", "5", "10", "15", "20", "25", "30");

                arrowLengthOffset.ComboBox.Changed += (o, e) =>
                {
                    if (arrowLengthOffset.ComboBox.ActiveText.Length < 1)
                    {
                        //Ignore the change until the user enters something.
                        return;
                    }
                    else if (arrowLengthOffset.ComboBox.ActiveText == "-")
                    {
                        //The user is trying to enter a negative value: ignore the change until the user enters more.
                        return;
                    }
                    else
                    {
                        double newLength = 10d;

                        if (Double.TryParse(arrowLengthOffset.ComboBox.ActiveText, out newLength))
                        {
                            if (newLength < -100d)
                            {
                                //Less than -100: change it to -100.
                                newLength = -100d;
                            }
                            else if (newLength > 100d)
                            {
                                //Greater than 100: change it to 100.
                                newLength = 100d;
                            }
                        }
                        else
                        {
                            //Not a number: wait until the user enters something.
                            return;
                        }

                        (arrowLengthOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newLength.ToString();

                        LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

                        if (activeEngine != null)
                        {
                            activeEngine.Arrow1.LengthOffset = newLength;
                            activeEngine.Arrow2.LengthOffset = newLength;

                            DrawActiveShape(false, false, true, false, false);

                            storePreviousSettings();
                        }
                    }
                };
            }

            if (arrowLengthOffsetPlus == null)
            {
                arrowLengthOffsetPlus          = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase length offset"));
                arrowLengthOffsetPlus.Clicked += new EventHandler(arrowLengthOffsetPlus_Clicked);
            }

            #endregion Length Offset


            if (showOtherArrowOptions)
            {
                tb.Add(arrowSizeLabel);
                tb.Add(arrowSizeMinus);
                tb.Add(arrowSize);
                tb.Add(arrowSizePlus);
                tb.Add(arrowAngleOffsetLabel);
                tb.Add(arrowAngleOffsetMinus);
                tb.Add(arrowAngleOffset);
                tb.Add(arrowAngleOffsetPlus);
                tb.Add(arrowLengthOffsetLabel);
                tb.Add(arrowLengthOffsetMinus);
                tb.Add(arrowLengthOffset);
                tb.Add(arrowLengthOffsetPlus);
            }
        }
示例#5
0
        protected override void BuildToolBar(Gtk.Toolbar tb)
        {
            base.BuildToolBar (tb);

            if (radius_sep == null)
                radius_sep = new Gtk.SeparatorToolItem ();

            tb.AppendItem (radius_sep);

            if (radius_label == null)
                radius_label = new ToolBarLabel (string.Format ("  {0}: ", Catalog.GetString ("Radius")));

            tb.AppendItem (radius_label);

            if (radius_minus == null) {
                radius_minus = new ToolBarButton ("Toolbar.MinusButton.png", "", Catalog.GetString ("Decrease rectangle's corner radius"));
                radius_minus.Clicked += RadiusMinusButtonClickedEvent;
            }

            tb.AppendItem (radius_minus);

            if (radius == null)
                radius = new ToolBarComboBox (65, 2, true, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                "10", "11", "12", "13", "14", "15", "20", "25", "30", "35",
                "40", "45", "50", "55");

            tb.AppendItem (radius);

            if (radius_plus == null) {
                radius_plus = new ToolBarButton ("Toolbar.PlusButton.png", "", Catalog.GetString ("Increase rectangle's corner radius"));
                radius_plus.Clicked += RadiusPlusButtonClickedEvent;
            }

            tb.AppendItem (radius_plus);
        }
示例#6
0
        // Do this in a separate method so SelectTool can override it as
        // a no-op, but still get the BaseShape.OnBuildToolBar logic.
        protected virtual void BuildToolBar(Gtk.Toolbar tb)
        {
            if (brush_width_label == null)
            {
                brush_width_label = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Brush width")));
            }

            tb.AppendItem(brush_width_label);

            if (brush_width_minus == null)
            {
                brush_width_minus          = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease brush size"));
                brush_width_minus.Clicked += MinusButtonClickedEvent;
            }

            tb.AppendItem(brush_width_minus);

            if (brush_width == null)
            {
                brush_width = new ToolBarComboBox(65, 1, true, "1", "2", "3", "4", "5", "6", "7", "8", "9",
                                                  "10", "11", "12", "13", "14", "15", "20", "25", "30", "35",
                                                  "40", "45", "50", "55");
            }

            tb.AppendItem(brush_width);

            if (brush_width_plus == null)
            {
                brush_width_plus          = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase brush size"));
                brush_width_plus.Clicked += PlusButtonClickedEvent;
            }

            tb.AppendItem(brush_width_plus);

            if (ShowStrokeComboBox)
            {
                if (fill_sep == null)
                {
                    fill_sep = new Gtk.SeparatorToolItem();
                }

                tb.AppendItem(fill_sep);

                if (fill_label == null)
                {
                    fill_label = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Fill Style")));
                }

                tb.AppendItem(fill_label);

                if (fill_button == null)
                {
                    fill_button = new ToolBarDropDownButton();

                    fill_button.AddItem(Catalog.GetString("Outline Shape"), "ShapeTool.Outline.png", 0);
                    fill_button.AddItem(Catalog.GetString("Fill Shape"), "ShapeTool.Fill.png", 1);
                    fill_button.AddItem(Catalog.GetString("Fill and Outline Shape"), "ShapeTool.OutlineFill.png", 2);
                }

                tb.AppendItem(fill_button);
            }
        }
示例#7
0
        // Do this in a separate method so SelectTool can override it as
        // a no-op, but still get the BaseShape.OnBuildToolBar logic.
        protected virtual void BuildToolBar(Gtk.Toolbar tb)
        {
            if (brush_width_label == null)
                brush_width_label = new ToolBarLabel (string.Format (" {0}: ", Catalog.GetString ("Brush width")));

            tb.AppendItem (brush_width_label);

            if (brush_width_minus == null) {
                brush_width_minus = new ToolBarButton ("Toolbar.MinusButton.png", "", Catalog.GetString ("Decrease brush size"));
                brush_width_minus.Clicked += MinusButtonClickedEvent;
            }

            tb.AppendItem (brush_width_minus);

            if (brush_width == null)
                brush_width = new ToolBarComboBox (65, 1, true, "1", "2", "3", "4", "5", "6", "7", "8", "9",
                "10", "11", "12", "13", "14", "15", "20", "25", "30", "35",
                "40", "45", "50", "55");

            tb.AppendItem (brush_width);

            if (brush_width_plus == null) {
                brush_width_plus = new ToolBarButton ("Toolbar.PlusButton.png", "", Catalog.GetString ("Increase brush size"));
                brush_width_plus.Clicked += PlusButtonClickedEvent;
            }

            tb.AppendItem (brush_width_plus);

            if (ShowStrokeComboBox) {
                if (fill_sep == null)
                    fill_sep = new Gtk.SeparatorToolItem ();

                tb.AppendItem (fill_sep);

                if (fill_label == null)
                    fill_label = new ToolBarLabel (string.Format (" {0}: ", Catalog.GetString ("Fill Style")));

                tb.AppendItem (fill_label);

                if (fill_button == null) {
                    fill_button = new ToolBarDropDownButton ();

                    fill_button.AddItem (Catalog.GetString ("Outline Shape"), "ShapeTool.Outline.png", 0);
                    fill_button.AddItem (Catalog.GetString ("Fill Shape"), "ShapeTool.Fill.png", 1);
                    fill_button.AddItem (Catalog.GetString ("Fill and Outline Shape"), "ShapeTool.OutlineFill.png", 2);
                }

                tb.AppendItem (fill_button);
            }
        }
示例#8
0
		public override void HandleBuildToolBar(Gtk.Toolbar tb)
		{
			base.HandleBuildToolBar(tb);


			if (radius_sep == null)
				radius_sep = new Gtk.SeparatorToolItem();

			tb.AppendItem(radius_sep);

			if (radius_label == null)
				radius_label = new ToolBarLabel(string.Format("  {0}: ", Catalog.GetString("Radius")));

			tb.AppendItem(radius_label);

			if (radius_minus == null)
			{
				radius_minus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease shape's corner radius"));
				radius_minus.Clicked += RadiusMinusButtonClickedEvent;
			}

			tb.AppendItem(radius_minus);

			if (radius == null)
			{
				radius = new ToolBarComboBox(65, 16, true, "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
				"10", "11", "12", "13", "14", "15", "20", "25", "30", "40",
				"50", "60", "70", "80");

				radius.ComboBox.Changed += (o, e) =>
				{
					//Go through the Get/Set routine.
					Radius = Radius;
				};
			}

			tb.AppendItem(radius);

			if (radius_plus == null)
			{
				radius_plus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase shape's corner radius"));
				radius_plus.Clicked += RadiusPlusButtonClickedEvent;
			}

			tb.AppendItem(radius_plus);
		}
示例#9
0
        /// <summary>
        /// Creates a visual for a command.
        /// </summary>
        /// <param name="command">The command for which a visual must be created.</param>
        /// <param name="requiresParentCommand">If <c>true</c>, this command requires a parent visual.</param>
        /// <returns>The visual for the command.</returns>
        public static Gtk.Widget CreateVisualForCommand(this VisualRelayCommand command, bool requiresParentCommand)
        {
            System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(command.UniqueId), "Command's UniqueId is not defined.");
            Gtk.Widget visual        = null;
            var        parentCommand = (VisualRelayCommand)command.VisualParent;

            if (parentCommand != null)
            {
                var parentVisual = parentCommand.Visual.NativeVisual;
                if (parentVisual is Gtk.MenuBar)
                {
                    throw new System.InvalidOperationException("This should be done by CreateMenuItem!");

                    // Make a submenu for the command, and add the menu item to the menubar.
                    ////var menu = new Gtk.Menu() { Name = command.UniqueId };
                    ////var menuItem = new Gtk.MenuItem(command.MenuItemName) { Name = command.UniqueId, Submenu = menu };
                    ////((Gtk.MenuBar)parentVisual).Add(menuItem);
                    ////visual = menuItem;
                }
                if (parentVisual is Gtk.Toolbar)
                {
                    // The default toolbar command visual will be a button. If a different visual is desired,
                    // the CommandGroup should override visual creation for that command in ICommandGroup.CreateVisualForCommand().
                    var          toolbar = parentVisual as Gtk.Toolbar;
                    Gtk.ToolItem toolbarItem;
                    if (command.UniqueId == RootCommandGroup.ToolbarSeparatorCommand.UniqueId)
                    {
                        toolbarItem = new Gtk.SeparatorToolItem();
                    }
                    else
                    {
                        var group = command.GetCommandGroup() as CommandGroup;
                        toolbarItem = group.CreateToolbarItemForCommand(command).AsType <Gtk.ToolItem>();
                    }
                    var insertLocation = FindInsertLocation(parentCommand, command, false);
                    toolbar.Insert(toolbarItem, insertLocation); // if <0, appends
                    visual = toolbarItem;
                }
                if (parentCommand.Visual.IsEmpty)
                {
                    var group = parentCommand.GetCommandGroup();
                    if (group != null)
                    {
                        parentCommand.Visual = group.CreateVisualForCommand(parentCommand);
                    }
                }

                ErrorReporting.ReportErrorIf(requiresParentCommand && parentCommand.Visual.IsEmpty, "Failed to create parent visual for command: " + command.Name + "(" + command.UniqueId + ")");
                parentVisual = parentCommand.Visual;
            }

            DebugOutputIf(requiresParentCommand && (parentCommand == null), "No parent visual for command: " + command.Name + "(" + command.UniqueId + ")");
            if (visual != null)
            {
                visual.SetValue(CommandGroup.AttachedCommandPropertyName, command);
                var group = command.GetCommandGroup() as CommandGroup;
                if (group != null)
                {
                    var context = group.GetCommandContext(command, null);
                    visual.SetValue(IFakeDependencyObjectHelpers.DataContextPropertyName, context);
                    group.AttachCanExecuteChangeHandler(command);
                }
            }
            return(visual);
        }
示例#10
0
        public virtual void HandleBuildToolBar(Gtk.Toolbar tb)
        {
            if (brush_width_label == null)
                brush_width_label = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Brush width")));

            tb.AppendItem(brush_width_label);

            if (brush_width_minus == null)
            {
                brush_width_minus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease brush size"));
                brush_width_minus.Clicked += BrushMinusButtonClickedEvent;
            }

            tb.AppendItem(brush_width_minus);

			if (brush_width == null)
			{
				brush_width = new ToolBarComboBox(65, 1, true, "1", "2", "3", "4", "5", "6", "7", "8", "9",
					"10", "11", "12", "13", "14", "15", "20", "25", "30", "35", "40", "45", "50", "55");

				brush_width.ComboBox.Changed += (o, e) =>
				{
					ShapeEngine selEngine = SelectedShapeEngine;

					if (selEngine != null)
					{
						selEngine.BrushWidth = BrushWidth;
                        StorePreviousSettings ();
                        DrawActiveShape (false, false, true, false, false);
					}
				};
			}

            tb.AppendItem(brush_width);

            if (brush_width_plus == null)
            {
                brush_width_plus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase brush size"));
                brush_width_plus.Clicked += BrushPlusButtonClickedEvent;
            }

            tb.AppendItem(brush_width_plus);

            if (fill_sep == null)
                fill_sep = new Gtk.SeparatorToolItem();

            tb.AppendItem(fill_sep);

            if (fill_label == null)
                fill_label = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Fill Style")));

            tb.AppendItem(fill_label);

            if (fill_button == null)
            {
                fill_button = new ToolBarDropDownButton();

                fill_button.AddItem(Catalog.GetString("Outline Shape"), "ShapeTool.Outline.png", 0);
                fill_button.AddItem(Catalog.GetString("Fill Shape"), "ShapeTool.Fill.png", 1);
                fill_button.AddItem(Catalog.GetString("Fill and Outline Shape"), "ShapeTool.OutlineFill.png", 2);
            }

            tb.AppendItem(fill_button);

			if (shape_type_sep == null)
				shape_type_sep = new Gtk.SeparatorToolItem();

			tb.AppendItem(shape_type_sep);

			if (shape_type_label == null)
				shape_type_label = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Shape Type")));

			tb.AppendItem(shape_type_label);

			if (shape_type_button == null)
			{
				shape_type_button = new ToolBarDropDownButton();

				shape_type_button.AddItem(Catalog.GetString("Open Line/Curve Series"), "Tools.Line.png", 0);
				shape_type_button.AddItem(Catalog.GetString("Closed Line/Curve Series"), "Tools.Rectangle.png", 1);
				shape_type_button.AddItem(Catalog.GetString("Ellipse"), "Tools.Ellipse.png", 2);
				shape_type_button.AddItem(Catalog.GetString("Rounded Line Series"), "Tools.RoundedRectangle.png", 3);

				shape_type_button.SelectedItemChanged += (o, e) =>
				{
					ShapeTypes newShapeType = ShapeType;
					ShapeEngine selEngine = SelectedShapeEngine;

					if (selEngine != null)
					{
						//Verify that the tool needs to be switched.
						if (GetCorrespondingTool(newShapeType) != this.owner)
						{
							//Create a new ShapesModifyHistoryItem so that the changing of the shape type can be undone.
							PintaCore.Workspace.ActiveDocument.History.PushNewItem(new ShapesModifyHistoryItem(
								this, owner.Icon, Catalog.GetString("Changed Shape Type")));

							//Clone the old shape; it should be automatically garbage-collected. newShapeType already has the updated value.
							selEngine = selEngine.Convert(newShapeType, SelectedShapeIndex);

							int previousSSI = SelectedShapeIndex;

							ActivateCorrespondingTool(selEngine.ShapeType, true);

							SelectedShapeIndex = previousSSI;

							//Draw the updated shape with organized points generation (for mouse detection). 
							DrawActiveShape(true, false, true, false, true);
						}
					}
				};
			}

			shape_type_button.SelectedItem = shape_type_button.Items[(int)owner.ShapeType];

			tb.AppendItem(shape_type_button);


            Gtk.ComboBox dpbBox = dash_pattern_box.SetupToolbar(tb);

            if (dpbBox != null)
            {
                dpbBox.Changed += (o, e) =>
                {
					ShapeEngine selEngine = SelectedShapeEngine;

					if (selEngine != null)
					{
						selEngine.DashPattern = dpbBox.ActiveText;
                        StorePreviousSettings ();
                        DrawActiveShape (false, false, true, false, false);
					}
                };
            }
        }
示例#11
0
		public override void HandleBuildToolBar(Gtk.Toolbar tb)
		{
			base.HandleBuildToolBar(tb);


			#region Show Arrows

			//Arrow separator.

			if (arrowSep == null)
			{
				arrowSep = new Gtk.SeparatorToolItem();

				showOtherArrowOptions = false;
			}

			tb.AppendItem(arrowSep);


			if (arrowLabel == null)
			{
				arrowLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Arrow")));
			}

			tb.AppendItem(arrowLabel);


			//Show arrow 1.

			showArrowOneBox = new Gtk.CheckButton("1");
			showArrowOneBox.Active = previousSettings1.Show;

			showArrowOneBox.Toggled += (o, e) =>
			{
				//Determine whether to change the visibility of Arrow options in the toolbar based on the updated Arrow showing/hiding.
				if (!showArrowOneBox.Active && !showArrowTwoBox.Active)
				{
					if (showOtherArrowOptions)
					{
						tb.Remove(arrowSizeLabel);
						tb.Remove(arrowSizeMinus);
						tb.Remove(arrowSize);
						tb.Remove(arrowSizePlus);
						tb.Remove(arrowAngleOffsetLabel);
						tb.Remove(arrowAngleOffsetMinus);
						tb.Remove(arrowAngleOffset);
						tb.Remove(arrowAngleOffsetPlus);
						tb.Remove(arrowLengthOffsetLabel);
						tb.Remove(arrowLengthOffsetMinus);
						tb.Remove(arrowLengthOffset);
						tb.Remove(arrowLengthOffsetPlus);

						showOtherArrowOptions = false;
					}
				}
				else
				{
					if (!showOtherArrowOptions)
					{
						tb.Add(arrowSizeLabel);
						tb.Add(arrowSizeMinus);
						tb.Add(arrowSize);
						tb.Add(arrowSizePlus);
						tb.Add(arrowAngleOffsetLabel);
						tb.Add(arrowAngleOffsetMinus);
						tb.Add(arrowAngleOffset);
						tb.Add(arrowAngleOffsetPlus);
						tb.Add(arrowLengthOffsetLabel);
						tb.Add(arrowLengthOffsetMinus);
						tb.Add(arrowLengthOffset);
						tb.Add(arrowLengthOffsetPlus);

						showOtherArrowOptions = true;
					}
				}

				LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

				if (activeEngine != null)
				{
					activeEngine.Arrow1.Show = showArrowOneBox.Active;

					DrawActiveShape(false, false, true, false, false);

					StorePreviousSettings();
				}
			};

			tb.AddWidgetItem(showArrowOneBox);


			//Show arrow 2.

			showArrowTwoBox = new Gtk.CheckButton("2");
			showArrowTwoBox.Active = previousSettings2.Show;

			showArrowTwoBox.Toggled += (o, e) =>
			{
				//Determine whether to change the visibility of Arrow options in the toolbar based on the updated Arrow showing/hiding.
				if (!showArrowOneBox.Active && !showArrowTwoBox.Active)
				{
					if (showOtherArrowOptions)
					{
						tb.Remove(arrowSizeLabel);
						tb.Remove(arrowSizeMinus);
						tb.Remove(arrowSize);
						tb.Remove(arrowSizePlus);
						tb.Remove(arrowAngleOffsetLabel);
						tb.Remove(arrowAngleOffsetMinus);
						tb.Remove(arrowAngleOffset);
						tb.Remove(arrowAngleOffsetPlus);
						tb.Remove(arrowLengthOffsetLabel);
						tb.Remove(arrowLengthOffsetMinus);
						tb.Remove(arrowLengthOffset);
						tb.Remove(arrowLengthOffsetPlus);

						showOtherArrowOptions = false;
					}
				}
				else
				{
					if (!showOtherArrowOptions)
					{
						tb.Add(arrowSizeLabel);
						tb.Add(arrowSizeMinus);
						tb.Add(arrowSize);
						tb.Add(arrowSizePlus);
						tb.Add(arrowAngleOffsetLabel);
						tb.Add(arrowAngleOffsetMinus);
						tb.Add(arrowAngleOffset);
						tb.Add(arrowAngleOffsetPlus);
						tb.Add(arrowLengthOffsetLabel);
						tb.Add(arrowLengthOffsetMinus);
						tb.Add(arrowLengthOffset);
						tb.Add(arrowLengthOffsetPlus);

						showOtherArrowOptions = true;
					}
				}

				LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

				if (activeEngine != null)
				{
					activeEngine.Arrow2.Show = showArrowTwoBox.Active;

					DrawActiveShape(false, false, true, false, false);

					StorePreviousSettings();
				}
			};

			tb.AddWidgetItem(showArrowTwoBox);

			#endregion Show Arrows


			#region Arrow Size

			if (arrowSizeLabel == null)
			{
				arrowSizeLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Size")));
			}

			if (arrowSizeMinus == null)
			{
				arrowSizeMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease arrow size"));
				arrowSizeMinus.Clicked += new EventHandler(arrowSizeMinus_Clicked);
			}

			if (arrowSize == null)
			{
				arrowSize = new ToolBarComboBox(65, 7, true,
					"3", "4", "5", "6", "7", "8", "9", "10", "12", "15", "18",
					"20", "25", "30", "40", "50", "60", "70", "80", "90", "100");

				arrowSize.ComboBox.Changed += (o, e) =>
				{
					if (arrowSize.ComboBox.ActiveText.Length < 1)
					{
						//Ignore the change until the user enters something.
						return;
					}
					else
					{
						double newSize = 10d;

						if (arrowSize.ComboBox.ActiveText == "-")
						{
							//The user is trying to enter a negative value: change it to 1.
							newSize = 1d;
						}
						else
						{
							if (Double.TryParse(arrowSize.ComboBox.ActiveText, out newSize))
							{
								if (newSize < 1d)
								{
									//Less than 1: change it to 1.
									newSize = 1d;
								}
								else if (newSize > 100d)
								{
									//Greater than 100: change it to 100.
									newSize = 100d;
								}
							}
							else
							{
								//Not a number: wait until the user enters something.
								return;
							}
						}

						(arrowSize.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newSize.ToString();

						LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

						if (activeEngine != null)
						{
							activeEngine.Arrow1.ArrowSize = newSize;
							activeEngine.Arrow2.ArrowSize = newSize;

							DrawActiveShape(false, false, true, false, false);

							StorePreviousSettings();
						}
					}
				};
			}

			if (arrowSizePlus == null)
			{
				arrowSizePlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase arrow size"));
				arrowSizePlus.Clicked += new EventHandler(arrowSizePlus_Clicked);
			}

			#endregion Arrow Size


			#region Angle Offset

			if (arrowAngleOffsetLabel == null)
			{
				arrowAngleOffsetLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Angle")));
			}

			if (arrowAngleOffsetMinus == null)
			{
				arrowAngleOffsetMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease angle offset"));
				arrowAngleOffsetMinus.Clicked += new EventHandler(arrowAngleOffsetMinus_Clicked);
			}

			if (arrowAngleOffset == null)
			{
				arrowAngleOffset = new ToolBarComboBox(65, 9, true,
					"-30", "-25", "-20", "-15", "-10", "-5", "0", "5", "10", "15", "20", "25", "30");

				arrowAngleOffset.ComboBox.Changed += (o, e) =>
				{
					if (arrowAngleOffset.ComboBox.ActiveText.Length < 1)
					{
						//Ignore the change until the user enters something.
						return;
					}
					else if (arrowAngleOffset.ComboBox.ActiveText == "-")
					{
						//The user is trying to enter a negative value: ignore the change until the user enters more.
						return;
					}
					else
					{
						double newAngle = 15d;

						if (Double.TryParse(arrowAngleOffset.ComboBox.ActiveText, out newAngle))
						{
							if (newAngle < -89d)
							{
								//Less than -89: change it to -89.
								newAngle = -89d;
							}
							else if (newAngle > 89d)
							{
								//Greater than 89: change it to 89.
								newAngle = 89d;
							}
						}
						else
						{
							//Not a number: wait until the user enters something.
							return;
						}

						(arrowAngleOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newAngle.ToString();

						LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

						if (activeEngine != null)
						{
							activeEngine.Arrow1.AngleOffset = newAngle;
							activeEngine.Arrow2.AngleOffset = newAngle;

							DrawActiveShape(false, false, true, false, false);

							StorePreviousSettings();
						}
					}
				};
			}

			if (arrowAngleOffsetPlus == null)
			{
				arrowAngleOffsetPlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase angle offset"));
				arrowAngleOffsetPlus.Clicked += new EventHandler(arrowAngleOffsetPlus_Clicked);
			}

			#endregion Angle Offset


			#region Length Offset

			if (arrowLengthOffsetLabel == null)
			{
				arrowLengthOffsetLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Length")));
			}

			if (arrowLengthOffsetMinus == null)
			{
				arrowLengthOffsetMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease length offset"));
				arrowLengthOffsetMinus.Clicked += new EventHandler(arrowLengthOffsetMinus_Clicked);
			}

			if (arrowLengthOffset == null)
			{
				arrowLengthOffset = new ToolBarComboBox(65, 8, true,
					"-30", "-25", "-20", "-15", "-10", "-5", "0", "5", "10", "15", "20", "25", "30");

				arrowLengthOffset.ComboBox.Changed += (o, e) =>
				{
					if (arrowLengthOffset.ComboBox.ActiveText.Length < 1)
					{
						//Ignore the change until the user enters something.
						return;
					}
					else if (arrowLengthOffset.ComboBox.ActiveText == "-")
					{
						//The user is trying to enter a negative value: ignore the change until the user enters more.
						return;
					}
					else
					{
						double newLength = 10d;

						if (Double.TryParse(arrowLengthOffset.ComboBox.ActiveText, out newLength))
						{
							if (newLength < -100d)
							{
								//Less than -100: change it to -100.
								newLength = -100d;
							}
							else if (newLength > 100d)
							{
								//Greater than 100: change it to 100.
								newLength = 100d;
							}
						}
						else
						{
							//Not a number: wait until the user enters something.
							return;
						}

						(arrowLengthOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newLength.ToString();

						LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine;

						if (activeEngine != null)
						{
							activeEngine.Arrow1.LengthOffset = newLength;
							activeEngine.Arrow2.LengthOffset = newLength;

							DrawActiveShape(false, false, true, false, false);

							StorePreviousSettings();
						}
					}
				};
			}

			if (arrowLengthOffsetPlus == null)
			{
				arrowLengthOffsetPlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase length offset"));
				arrowLengthOffsetPlus.Clicked += new EventHandler(arrowLengthOffsetPlus_Clicked);
			}

			#endregion Length Offset

			
			if (showOtherArrowOptions)
			{
				tb.Add(arrowSizeLabel);
				tb.Add(arrowSizeMinus);
				tb.Add(arrowSize);
				tb.Add(arrowSizePlus);
				tb.Add(arrowAngleOffsetLabel);
				tb.Add(arrowAngleOffsetMinus);
				tb.Add(arrowAngleOffset);
				tb.Add(arrowAngleOffsetPlus);
				tb.Add(arrowLengthOffsetLabel);
				tb.Add(arrowLengthOffsetMinus);
				tb.Add(arrowLengthOffset);
				tb.Add(arrowLengthOffsetPlus);
			}
		}
示例#12
0
 private void ConstructSeparatorToolItem3()
 {
     Debug.WriteLine("ConstructSeparatorToolItem3");
     separatorToolItem3 = new Gtk.SeparatorToolItem
     {
         Name = "separatorToolItem3",
         Visible = true,
     };
 }