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); } }
public void fill() { Gtk.Button cancel = new Gtk.Button("Cancel scan"); Gtk.VSeparator sep = new Gtk.VSeparator(); cancel.Clicked += delegate(object sender, EventArgs args) { _fill_canceled = true; }; bar.Add(sep); sep.Show(); bar.Add(cancel); cancel.Show(); bar.Show(); getSheets().Clear(); basedir = MySource.getCueSheetDir(); Hyena.Log.Information("Base directory=" + basedir); if (basedir != null) { _fill_ready = false; _fill_count = 0; _fill_dir_count = 0; _fill_canceled = false; _fill_cues.Clear(); _fill_dirs.Clear(); fill(basedir); GLib.Timeout.Add(500, delegate() { if (_fill_ready || _fill_canceled) { try { Hyena.Log.Information("Reload albums"); MySource.getAlbumModel().Reload(); Hyena.Log.Information(MySource.getAlbumModel().Count.ToString()); Hyena.Log.Information("Reload artists"); MySource.getArtistModel().Reload(); Hyena.Log.Information(MySource.getArtistModel().Count.ToString()); Hyena.Log.Information("Reload composers"); MySource.getComposerModel().Reload(); Hyena.Log.Information(MySource.getComposerModel().Count.ToString()); Hyena.Log.Information("Reload genres"); MySource.getGenreModel().Reload(); Hyena.Log.Information(MySource.getGenreModel().Count.ToString()); Hyena.Log.Information("Reload tracks"); MySource.getTrackModel().Reload(); Hyena.Log.Information("Reload play lists"); MySource.getPlayListsModel().Reload(); Hyena.Log.Information("Reloaded all"); } catch (System.Exception e) { Hyena.Log.Information(e.ToString()); } Hyena.Log.Information("Reloaded"); filling.Text = ""; bar.Remove(sep); bar.Remove(cancel); bar.Hide(); FillLibrary(); return(false); } else { return(true); } }); } }