Exemple #1
0
        private void RenderFrets(Graphics g)
        {
            Pen fretPen = null;
            Pen nutPen  = GetPen(DisplayConfig.Frets.Color, 1);

            switch (DisplayConfig.Frets.RenderMode)
            {
            default:
            case LineRenderMode.PlainLine:
                fretPen = GetPen(DisplayConfig.Frets.Color, 1);
                break;

            case LineRenderMode.RealWidth:
                fretPen = GetPen(DisplayConfig.Frets.Color, DisplayConfig.Frets.RenderWidth);
                break;

            case LineRenderMode.RealisticLook:
                fretPen = GetPen(Color.DarkGray, DisplayConfig.Frets.RenderWidth);
                break;
            }

            foreach (var fretLine in CurrentLayout.VisualElements.OfType <FretLine>())
            {
                var penToUse   = fretLine.IsNut ? nutPen : fretPen;
                var fretPoints = fretLine.Points.Select(p => PointToDisplay(p)).ToArray();

                if (DisplayConfig.ExtendFrets && fretLine.Tag is ILayoutLine layoutLine)
                {
                    fretPoints = layoutLine.GetLinePoints()
                                 .Select(x => PointToDisplay(x)).ToArray();
                }

                if (fretLine.IsStraight || CurrentLayout.FretInterpolation == FretInterpolationMethod.Linear)
                {
                    g.DrawLines(penToUse, fretPoints);
                }
                else
                {
                    g.DrawCurve(penToUse, fretPoints, 0.6f);
                }

                if (DisplayConfig.Frets.DisplayAccuratePositions && fretLine.Strings.Count() > 1)
                {
                    g.DrawLines(nutPen, fretLine.Segments.Where(s => !s.IsVirtual)
                                .Select(s => PointToDisplay(s.PointOnString)).ToArray());
                }
            }

            if (DisplayConfig.Frets.DisplayBridgeLine)
            {
                var bridgeLine = CurrentLayout.GetElement <LayoutPolyLine>(x => x.ElementType == VisualElementType.BridgeLine);
                if (bridgeLine != null)
                {
                    DrawLine(g, bridgeLine, nutPen);
                }
            }

            nutPen.Dispose();
            fretPen.Dispose();
        }
        /// <summary>
        /// Reconfigure components in response to layout change.
        /// Happens After OnApplyTemplate.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Chart_LayoutUpdated(object sender, object e)
        {
            // This is (NaN,NaN) if we haven't been sized yet
            var sz = new Size(ActualWidth, ActualHeight);

            //_trace.Verbose($"LayoutUpdated ({sz.Width}x{sz.Height})");
            if (!double.IsNaN(sz.Width) && !double.IsNaN(sz.Height))
            {
                // we are sized; see if dimensions actually changed
                if (sz.Width == 0 || sz.Height == 0)
                {
                    return;
                }
                if (CurrentLayout.IsSizeChanged(sz))
                {
                    _trace.Verbose($"LayoutUpdated.trigger ({sz.Width}x{sz.Height})");
                    var ls = new LayoutState()
                    {
                        Dimensions = sz, Layout = CurrentLayout.Layout
                    };
                    try {
                        RenderComponents(ls);
                    }
                    catch (Exception ex) {
                        _trace.Error($"{ex}");
                    }
                    finally {
                        CurrentLayout = ls;
                    }
                }
            }
        }
Exemple #3
0
 private void dgvScaleLengths_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (!IsLoading && CurrentLayout != null && e.RowIndex >= 0)
     {
         CurrentLayout.RebuildLayout();
     }
 }
 /// <summary>
 /// Clears the dragging of notes on A layout. If stuck in dragmode
 /// </summary>
 public void ClearDraggingOfNotesOnALayout()
 {
     if (CurrentLayout != null)
     {
         CurrentLayout.ClearDrag();
     }
 }
Exemple #5
0
        private void RenderGuideLines(Graphics g)
        {
            using (var guidePen = GetPen(Color.Gainsboro, 1))
            {
                guidePen.DashPattern = new float[] { 6, 4, 2, 4 };

                if (DisplayConfig.ShowFingerboard && DisplayConfig.Fingerboard.ContinueLines)
                {
                    var endPoints = new List <PointM>();

                    foreach (var line in CurrentLayout.GetElements <LayoutLine>(l =>
                                                                                l.ElementType == VisualElementType.FingerboardContinuation))
                    {
                        DrawLine(g, line, guidePen);
                        endPoints.Add(line.P2);
                    }

                    var pt1 = endPoints.OrderBy(pt => pt.X).First();
                    var pt2 = endPoints.OrderByDescending(pt => pt.X).First();
                    DrawLine(g, guidePen, pt1, pt2);
                }

                foreach (var line in CurrentLayout.GetElements <LayoutLine>(l =>
                                                                            l.ElementType == VisualElementType.GuideLine))
                {
                    DrawLine(g, line, guidePen);
                }
            }
        }
        /// <summary>
        /// Moves a tilable Element with the ID between two Elements defined by "BeforeID" and "AfterID".
        /// The ID-Element will have the Value (GetValue(AfterId,isOu) - GetValue(BeforeId,isOU))/2
        ///
        /// The result will be:
        /// GetValue(BeforeId,isOu) < GetValue(ID,isOu) < GetValue(AfterId,isOu)
        /// </summary>
        /// <param name="ID">The Element to move to a new position (scope isOu!)</param>
        /// <param name="BeforeId">The Element where the ID-Element should be placed after (scope isOu!)</param>
        /// <param name="AfterId">The Element where the ID-Element should be placed before (scope isOu!)</param>
        /// <param name="isOu"></param>
        /// <param name="isOtherOu">defines if the element before is an OU</param>
        /// <param name="isOtherOu">defines if the element after is an OU</param>
        public void MoveBetween(int ID, int BeforeId, int AfterId, bool isOu, bool isBeforeOu, bool isAfterOu)
        {
            float a = CurrentLayout.GetValue(BeforeId, isBeforeOu);
            float b = CurrentLayout.GetValue(AfterId, isAfterOu);
            float v = (b + a) / 2.0f;

            CurrentLayout.SetValue(ID, isOu, v);
        }
 private void chkCompensateGauge_CheckedChanged(object sender, EventArgs e)
 {
     if (!IsLoading && CurrentLayout != null)
     {
         CurrentLayout.Margins.CompensateStringGauge = chkCompensateGauge.Checked;
         CurrentLayout.RebuildLayout();
     }
 }
 private void nbxNumberOfStrings_ValueChanged(object sender, EventArgs e)
 {
     if (!IsLoading && CurrentLayout != null)
     {
         CurrentLayout.NumberOfStrings = (int)nbxNumberOfStrings.Value;
         CurrentLayout.RebuildLayout();
     }
 }
 private void cboBridgeSpacingAlignment_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!IsLoading && CurrentLayout != null && !FlagManager["UpdateComboboxes"])
     {
         CurrentLayout.SimpleStringSpacing.BridgeAlignment = (StringSpacingAlignment)cboBridgeSpacingAlignment.SelectedValue;
         CurrentLayout.RebuildLayout();
     }
 }
 private void chkLeftHanded_CheckedChanged(object sender, EventArgs e)
 {
     if (!IsLoading && CurrentLayout != null)
     {
         CurrentLayout.LeftHanded = chkLeftHanded.Checked;
         CurrentLayout.RebuildLayout();
     }
 }
 private void mtbLastFret_ValueChanged(object sender, EventArgs e)
 {
     if (!IsLoading && CurrentLayout != null)
     {
         CurrentLayout.Margins.LastFret = mtbLastFret.Value;
         CurrentLayout.RebuildLayout();
     }
 }
        /// <summary>
        /// Moves the Element with the ID after an element of the same type with the OtherID
        /// GetValue(OtherID,isOU) < GetValue(Id,isOu) < GetValue(all but ID, isOu)
        /// </summary>
        /// <param name="ID">Element which should be moved</param>
        /// <param name="OtherId">Element where the element above should be placed after</param>
        /// <param name="isOu">defines if it is an ou or an MS</param>
        /// <param name="isOtherOu">defines if the other element is an OU</param>
        public void MoveAfter(int ID, int OtherId, bool isOu, bool isOtherOu)
        {
            float b = CurrentLayout.GetValueAfter(OtherId, isOtherOu);
            float a = CurrentLayout.GetValue(OtherId, isOtherOu);
            float v = (a + b) / 2.0f;

            CurrentLayout.SetValue(ID, isOu, v);
        }
Exemple #13
0
 private void mtbBassLength_ValueChanged(object sender, EventArgs e)
 {
     if (!IsLoading && CurrentLayout != null && EditMode == ScaleLengthType.Dual)
     {
         CurrentLayout.DualScaleConfig.Bass = mtbBassLength.Value;
         CurrentLayout.RebuildLayout();
     }
 }
Exemple #14
0
 /// <summary>
 /// Remove the selected element
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DeleteButton_Click(object sender, EventArgs e)
 {
     if (CurrentElement != null)
     {
         CurrentLayout.DeleteElement(CurrentElement);
         SelectElement(null);
         RebuildElementsBox();
     }
 }
 private void dgvStrings_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (!IsLoading && !FlagManager["FillPivotGrid"] && CurrentLayout != null)
     {
         SetCellValue(e.ColumnIndex, e.RowIndex, dgvStrings[e.ColumnIndex, e.RowIndex].Value);
         CurrentLayout.RebuildLayout();
         dgvStrings.AutoResizeColumn(e.ColumnIndex, DataGridViewAutoSizeColumnMode.AllCells);
     }
 }
        /// <summary>
        /// Moves the Element with the ID before an element of the same type with the OtherID
        /// GetValue(all but ID, isOu) < GetValue(Id,isOu) < GetValue(OtherID,isOU)
        ///
        /// Both IDs must be in the same OU!
        ///
        /// </summary>
        /// <param name="ID">Element which should be moved</param>
        /// <param name="OtherId">Element where the element above should be placed before</param>
        /// <param name="isOu">defines if it is an ou or an MS</param>
        /// <param name="isOtherOu">defines if the other element is an OU</param>
        public void MoveBefore(int ID, int OtherId, bool isOu, bool isOtherOu)
        {
            //Console.WriteLine("Move before {0},{1},{2},{3}", ID, OtherId, isOu, isOtherOu);
            float b = CurrentLayout.GetValueBefore(OtherId, isOtherOu);
            float a = CurrentLayout.GetValue(OtherId, isOtherOu);
            float v = (a + b) / 2.0f;

            CurrentLayout.SetValue(ID, isOu, v);
            //Console.WriteLine("SetValue: {0},{1},{2}", ID, isOu, v);
        }
 private void mtbBridgeSpread_ValueChanged(object sender, EventArgs e)
 {
     if (!IsLoading && CurrentLayout != null && !FlagManager["UpdateSpacing"])
     {
         CurrentLayout.SimpleStringSpacing.StringSpreadAtBridge = mtbBridgeSpread.Value;
         using (FlagManager.UseFlag("UpdateSpacing"))
             mtbBridgeSpacing.Value = CurrentLayout.SimpleStringSpacing.StringSpacingAtBridge;
         CurrentLayout.RebuildLayout();
     }
 }
Exemple #18
0
        protected override void Draw(GameTime gameTime)
        {
            _renderer.BeginDraw();
            CurrentLayout.Draw(_renderer, _isDebugging);
            Singletons.Draw(_renderer, _isDebugging);
            Singletons.DrawGUI(_renderer);
            _renderer.EndDraw();

            base.Draw(gameTime);
        }
 private void nbxNumberOfFrets_ValueChanged(object sender, EventArgs e)
 {
     if (!IsLoading && CurrentLayout != null)
     {
         CurrentLayout.StartBatchChanges("NumberOfFrets");
         CurrentLayout.Strings.SetAll(s => s.NumberOfFrets, (int)nbxNumberOfFrets.Value);
         CurrentLayout.FinishBatchChanges();
         CurrentLayout.RebuildLayout();
     }
 }
Exemple #20
0
        public void SwapInView(UIView oldView, UIView newView)
        {
            var cell = CurrentLayout.FindCell(oldView);

            if (cell == null)
            {
                throw new ArgumentException($"Grid {ID}: oldView {oldView} is not in the Grid");
            }
            cell.View = newView;
            oldView.RemoveFromSuperview();
            AddSubview(newView);
            SetNeedsLayout();
        }
Exemple #21
0
        /// <summary>
        /// save the asset to the manager
        /// </summary>
        public override void Save()
        {
            StringBuilder sb = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(sb))
                CurrentLayout.Save(writer);

            string      xml = sb.ToString();
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            ResourceManager.AddAsset <Layout>(CurrentLayout.Name, doc.DocumentElement);
        }
Exemple #22
0
 private void mtbTrebleLength_ValueChanged(object sender, EventArgs e)
 {
     if (!IsLoading && CurrentLayout != null)
     {
         if (EditMode == ScaleLengthType.Single)
         {
             CurrentLayout.SingleScaleConfig.Length = mtbTrebleLength.Value;
         }
         else if (EditMode == ScaleLengthType.Dual)
         {
             CurrentLayout.DualScaleConfig.Treble = mtbTrebleLength.Value;
         }
         CurrentLayout.RebuildLayout();
     }
 }
Exemple #23
0
        protected override void Update(GameTime gameTime)
        {
            TotalTime = (float)gameTime.TotalGameTime.TotalSeconds;
            Singletons.HandleInput(gameTime);

            if (!_paused)
            {
                HandleLayoutChange();

                Singletons.Tick(gameTime);
                CurrentLayout.Tick(gameTime);
                CurrentLayout.PostTick(gameTime);
            }

            base.Update(gameTime);
        }
Exemple #24
0
        private void nubMultiScaleRatio_ValueChanged(object sender, EventArgs e)
        {
            if (!IsLoading && CurrentLayout != null && EditMode == ScaleLengthType.Dual && !FlagManager["AdjustPositionRatio"])
            {
                var closestFret = SelectClosestFretPosition(nubMultiScaleRatio.Value);

                if (closestFret != null)
                {
                    using (FlagManager.UseFlag("DetermineFretAlignment"))
                        nubMultiScaleRatio.Value = closestFret.PositionRatio; // Math.Round(closestFret.PositionRatio, 4);
                }

                CurrentLayout.DualScaleConfig.PerpendicularFretRatio = nubMultiScaleRatio.Value;
                CurrentLayout.RebuildLayout();
            }
        }
        /// <summary>
        /// Handels a LayoutChangeCommand in this LayoutManager.
        /// Commands are only handled if Layouter is defined and isPowerwall is true!
        /// </summary>
        /// <param name="cmd">The incomming LayoutChangeCommand</param>
        private void IncommingLayoutChanges(LayoutChangeCommand cmd)
        {
            if (ConfigClass.IsPowerwall)
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    switch (cmd.CommandType)
                    {
                    case LayoutCommand.MS_STATE_CHANGED:
                        CurrentLayout.SetState(cmd.ID, cmd.MSState());
                        break;

                    case LayoutCommand.OU_STATE_CHANGED:
                        CurrentLayout.SetState(cmd.ID, cmd.OUState());
                        break;

                    case LayoutCommand.MS_VALUE_CHANGED:
                        CurrentLayout.SetValue(cmd.ID, false, cmd.MSValue());
                        break;

                    case LayoutCommand.OU_VALUE_CHANGED:
                        CurrentLayout.SetValue(cmd.ID, true, cmd.OUValue());
                        break;

                    case LayoutCommand.PROPERTY_CHANGED:
                        CurrentLayout.SetProperty(cmd.Property().Key, cmd.Property().Value);
                        break;

                    case LayoutCommand.UPDATE_COMPLETE_LAYOUT:
                        CurrentLayout = cmd.GetLayout();
                        break;

                    case LayoutCommand.PRIORITY_LIST_CHANGED:
                        this.PluginPriority = cmd.GetPluginPriorityList();
                        break;

                    default:
                        throw new ArgumentOutOfRangeException("LayoutCommand is not known!");
                    }
                });
            }
            else
            {
                throw new ArgumentOutOfRangeException("We are no Powerwall or no Layouter is defined!");
            }
        }
Exemple #26
0
        /// <summary>
        /// Time to paint my dear !
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RenderControl_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            RenderControl.MakeCurrent();

            // Stop the draw timer
            DrawTimer.Stop();

            // Clear the background
            Display.ClearBuffers();

            Batch.Begin();

            // Background texture


            // Background texture
            Rectangle dst = new Rectangle(Point.Empty, RenderControl.Size);

            Batch.Draw(CheckerBoard, dst, dst, Color.White);


            // Draw the layout
            CurrentLayout.Draw(Batch);


            // Draw the selection box
            SelectionBox.Draw(Batch);

            // If no action and mouse over an element, draw its bounding box
            if (SelectionBox.MouseTool == MouseTools.NoTool)
            {
                Control elem = FindElementAt(RenderControl.PointToClient(System.Windows.Forms.Control.MousePosition));
                if (elem != null)
                {
                    //Display.DrawRectangle(elem.Rectangle, Color.White);
                }
            }

            Batch.End();
            RenderControl.SwapBuffers();

            // Start the draw timer
            DrawTimer.Start();
        }
 private void cboBridgeSpacingMethod_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!IsLoading && CurrentLayout != null && !FlagManager["UpdateComboboxes"])
     {
         CurrentLayout.SimpleStringSpacing.BridgeSpacingMode = (StringSpacingMethod)cboBridgeSpacingMethod.SelectedValue;
         CurrentLayout.RebuildLayout();
     }
     if (cboBridgeSpacingMethod.SelectedItem != null)
     {
         if ((StringSpacingMethod)cboBridgeSpacingMethod.SelectedValue == StringSpacingMethod.EqualSpacing)
         {
             lblBridgeStringSpacing.Text = Text_AvgSpacing;
         }
         else
         {
             lblBridgeStringSpacing.Text = Text_Spacing;
         }
     }
 }
 private void Chart_SizeChanged(object sender, SizeChangedEventArgs e)
 {
         #if false
     _trace.Verbose($"SizeChanged prev({e.PreviousSize.Width}x{e.PreviousSize.Height}) new({e.NewSize.Width}x{e.NewSize.Height})");
     if (e.NewSize.Width == 0 || e.NewSize.Height == 0)
     {
         return;
     }
     if (CurrentLayout.IsSizeChanged(e.NewSize))
     {
         var ls = new LayoutState()
         {
             Dimensions = e.NewSize, Layout = CurrentLayout.Layout
         };
         RenderComponents(ls);
         CurrentLayout = ls;
     }
         #endif
 }
Exemple #29
0
        private void rbScaleLengthMode_CheckedChanged(object sender, EventArgs e)
        {
            if (!IsLoading && !FlagManager["SetMode"] && (sender as RadioButton).Checked)
            {
                if (enteringControl)//fallback to prevent Windows to force check the last clicked radiobutton
                {
                    SetSelectedEditMode(EditMode);
                    return;
                }

                EditMode = GetSelectedEditMode();
                if (CurrentLayout != null)
                {
                    CurrentLayout.ScaleLengthMode = EditMode;
                    CurrentLayout.RebuildLayout();
                }
                ApplyLayout();
            }
        }
Exemple #30
0
        /// <summary>
        /// Select an element by its name
        /// </summary>
        /// <param name="name"></param>
        void SelectElement(string name)
        {
            CurrentElement = CurrentLayout.GetElement(name);

            if (CurrentElement != null)
            {
                SelectionBox.Rectangle            = CurrentElement.Rectangle;
                ElementPropertyBox.SelectedObject = CurrentElement;
                ElementsBox.SelectedItem          = name;
            }
            else
            {
                SelectionBox.Rectangle            = Rectangle.Empty;
                ElementPropertyBox.SelectedObject = null;
                if (ElementsBox.SelectedIndex != -1)
                {
                    ElementsBox.SetSelected(ElementsBox.SelectedIndex, false);
                }
            }
        }