Esempio n. 1
0
        private void newButton_Click(object sender, RoutedEventArgs e)
        {
            current = new glyph(idCtr++);
            glyphList.AddLast(current);

            writerBox.IsEnabled = true;
            populateFrame();

            xGridSizeTextbox.IsEnabled = true;
            yGridSizeTextbox.IsEnabled = true;
            xGridSizeTextbox.Text      = "" + current.ePD.gridSizeX;
            yGridSizeTextbox.Text      = "" + current.ePD.gridSizeY;

            previewLeftCount = 0;

            UpdatePreviewBox();

            Update();
        }
Esempio n. 2
0
        private void workArea_MouseDown(object sender, MouseButtonEventArgs e)
        {
            double y = Mouse.GetPosition(workArea).Y;
            double x = Mouse.GetPosition(workArea).X;

            foreach (glyph g in glyphList)
            {
                if (x >= g.worldX && x <= g.worldX + 50 &&
                    y >= g.worldY && y <= g.worldY + 50)
                {
                    current               = g;
                    writerBox.IsEnabled   = true;
                    xGridSizeTextbox.Text = "" + current.ePD.gridSizeX;
                    yGridSizeTextbox.Text = "" + current.ePD.gridSizeY;

                    UpdatePreviewBox();

                    populateFrame();
                }
            }

            Update();
        }
Esempio n. 3
0
        private void drawGlyph(glyph g, int xMargin, int yMargin)
        {
            if (current != null)
            {
                if (current.id == g.id)
                {
                    Rectangle highlight = new Rectangle();

                    highlight.Stroke          = getColor(3);
                    highlight.StrokeThickness = 2;
                    highlight.Margin          = new Thickness(xMargin - 5, yMargin - 5, 0, 0);
                    highlight.RadiusX         = highlight.RadiusY = 7;
                    highlight.Width           = highlight.Height = boxSize + 10;
                    workArea.Children.Add(highlight);
                }
            }

            if (g.sylableCount() == 0)
            {
                Rectangle blank = new Rectangle();
                blank.Fill    = getColor(4);
                blank.Margin  = new Thickness(xMargin + 10, yMargin + 10, 0, 0);
                blank.RadiusX = blank.RadiusY = 5;
                blank.Width   = blank.Height = boxSize * 0.6;
                workArea.Children.Add(blank);
            }
            else
            {
                double glyphBoundX1 = g.worldX, glyphBoundY1 = g.worldY;
                double glyphBoundX2 = g.worldX + boxSize, glyphBoundY2 = g.worldY + boxSize;

                foreach (glyph.syllable draw in g.syllableList)
                {
                    double relativeXMargin = draw.box.x1 * ((boxSize / g.ePD.gridSizeX));                       // - boxOverlap);
                    double relativeYMargin = draw.box.y1 * ((boxSize / g.ePD.gridSizeY));                       // - boxOverlap);
                    double smallXSize      = (((boxSize / g.ePD.gridSizeX)) * (draw.box.x2 - draw.box.x1 + 1)); // + boxOverlap;
                    double smallYSize      = (((boxSize / g.ePD.gridSizeY)) * (draw.box.y2 - draw.box.y1 + 1)); // + boxOverlap;

                    //preview box
                    // if(current.id == g.id)
                    //  makePreviewRect(draw);

                    if (relativeXMargin != 0)
                    {
                        relativeXMargin -= boxOverlap / 1;
                        smallXSize      += boxOverlap / 1;
                    }
                    if (relativeYMargin != 0)
                    {
                        relativeYMargin -= boxOverlap / 1;
                        smallYSize      += boxOverlap / 1;
                    }

                    if (relativeXMargin + smallXSize < boxSize)
                    {
                        smallXSize += boxOverlap;
                    }
                    if (relativeYMargin + smallYSize < boxSize)
                    {
                        smallYSize += boxOverlap;
                    }

                    /*if (smallXSize + relativeXMargin < g.worldX + boxSize)
                     *   smallXSize += boxOverlap;
                     * if (smallYSize + relativeYMargin < g.worldY + boxSize)
                     *   smallYSize += boxOverlap;*/


                    Rectangle small = new Rectangle();
                    small.Fill   = getColor(2);
                    small.Stroke = getColor(0);

                    small.Margin  = new Thickness(xMargin + relativeXMargin, yMargin + relativeYMargin, 0, 0);
                    small.RadiusX = small.RadiusY = boxSize * 0.1;
                    small.Width   = smallXSize;
                    small.Height  = smallYSize;
                    workArea.Children.Add(small);

                    TextBlock lab = new TextBlock();
                    lab.Text       = draw.listToken;
                    lab.FontSize   = 8;
                    lab.Margin     = new Thickness(xMargin + relativeXMargin + 2, yMargin + relativeYMargin + (smallYSize / 2) - 7, 0, 0);
                    lab.Foreground = getColor(0);
                    workArea.Children.Add(lab);
                }
            }

            /*switch(g.sylableCount())
             * {
             *  case 0:
             *      Rectangle blank = new Rectangle();
             *      blank.Fill = getColor(4);
             *      blank.Margin = new Thickness(xMargin + 10, yMargin + 10, 0, 0);
             *      blank.RadiusX = blank.RadiusY = 5;
             *      blank.Width = blank.Height = 30;
             *      workArea.Children.Add(blank);
             *      break;
             *  case 1:
             *      Rectangle one = new Rectangle();
             *
             *      one.Fill = getColor(2);
             *      one.Stroke = getColor(0);
             *      one.Margin = new Thickness(xMargin, yMargin, 0, 0);
             *      one.RadiusX = one.RadiusY = 10;
             *      one.Width = one.Height = 50;
             *      workArea.Children.Add(one);
             *      break;
             *  case 2:
             *      Rectangle two1 = new Rectangle();
             *      Rectangle two2 = new Rectangle();
             *
             *      two1.Fill = getColor(2);
             *      two1.Stroke = getColor(0);
             *      two1.Margin = new Thickness(xMargin, yMargin, 0, 0);
             *      two1.RadiusX = two1.RadiusY = 7;
             *      two1.Width = 27;
             *      two1.Height = 50;
             *      workArea.Children.Add(two1);
             *
             *      two2.Fill = getColor(2);
             *      two2.Stroke = getColor(0);
             *      two2.Margin = new Thickness(xMargin+23, yMargin, 0, 0);
             *      two2.RadiusX = two2.RadiusY = 7;
             *      two2.Width = 27;
             *      two2.Height = 50;
             *      workArea.Children.Add(two2);
             *      break;
             *  case 3:
             *      Rectangle three1 = new Rectangle();
             *      Rectangle three2 = new Rectangle();
             *      Rectangle three3 = new Rectangle();
             *
             *      three1.Fill = getColor(2);
             *      three1.Stroke = getColor(0);
             *      three1.Margin = new Thickness(xMargin, yMargin, 0, 0);
             *      three1.RadiusX = three1.RadiusY = 7;
             *      three1.Width = 27;
             *      three1.Height = 50;
             *      workArea.Children.Add(three1);
             *
             *      three2.Fill = getColor(2);
             *      three2.Stroke = getColor(0);
             *      three2.Margin = new Thickness(xMargin + 23, yMargin, 0, 0);
             *      three2.RadiusX = three2.RadiusY = 5;
             *      three2.Width = 27;
             *      three2.Height = 27;
             *      workArea.Children.Add(three2);
             *
             *      three3.Fill = getColor(2);
             *      three3.Stroke = getColor(0);
             *      three3.Margin = new Thickness(xMargin + 23, yMargin+23, 0, 0);
             *      three3.RadiusX = three3.RadiusY = 5;
             *      three3.Width = 27;
             *      three3.Height = 27;
             *      workArea.Children.Add(three3);
             *      break;
             *  case 4:
             *      Rectangle temp = new Rectangle();
             *      Rectangle temp2 = new Rectangle();
             *      Rectangle temp3 = new Rectangle();
             *      Rectangle temp4 = new Rectangle();
             *
             *      temp.Fill = getColor(2);
             *      temp.Stroke = getColor(0);
             *      temp.Margin = new Thickness(xMargin + 23, yMargin + 23, 0, 0);
             *      temp.RadiusX = temp.RadiusY = 5;
             *      temp.Width = temp.Height = 27;
             *      workArea.Children.Add(temp);
             *
             *      temp2.Fill = getColor(2);
             *      temp2.Stroke = getColor(0);
             *      temp2.Margin = new Thickness(xMargin + 23, yMargin, 0, 0);
             *      temp2.RadiusX = temp2.RadiusY = 5;
             *      temp2.Width = temp2.Height = 27;
             *      workArea.Children.Add(temp2);
             *
             *      temp3.Fill = getColor(2);
             *      temp3.Stroke = getColor(0);
             *      temp3.RadiusX = temp3.RadiusY = 5;
             *      temp3.Width = temp3.Height = 27;
             *      temp3.Margin = new Thickness(xMargin, yMargin + 23, 0, 0);
             *      workArea.Children.Add(temp3);
             *
             *      temp4.Fill = getColor(2);
             *      temp4.Stroke = getColor(0);
             *      temp4.RadiusX = temp4.RadiusY = 5;
             *      temp4.Width = temp4.Height = 27;
             *      temp4.Margin = new Thickness(xMargin, yMargin, 0, 0);
             *      workArea.Children.Add(temp4);
             *      break;
             *  default:
             *
             *      break;
             * }  */
        }