예제 #1
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
        private void arrangeInColumns(IEnumerable <Label> workingData, int nCol, Point origin)
        {
            int nx, ny;
            int count = 1;

            nx = origin.X;
            ny = origin.Y;
            DrawingControl.SuspendDrawing(pContainer);
            foreach (Label l in workingData)
            {
                l.Location = new Point(nx, ny);
                if (nCol > 1)
                {
                    nx = origin.X + columnSpacing * (count / labelPerColumn);
                    ny = origin.Y + globalGridSize * (count % labelPerColumn);
                }
                else
                {
                    nx = origin.X;
                    ny = origin.Y + globalGridSize * count;
                }
                count++;
            }
            DrawingControl.ResumeDrawing(pContainer);
            setSavedStatus(false);
        }
예제 #2
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
 private void openFile(string filename)
 {
     clearAll();
     workingFile = filename;
     System.IO.Stream stream = File.OpenRead(filename);
     using (System.IO.StreamReader reader = new System.IO.StreamReader(stream))
     {
         DrawingControl.SuspendDrawing(pContainer);
         while (!reader.EndOfStream)
         {
             string   line = reader.ReadLine();
             string[] d    = line.Split(token);
             string   txt  = String.Join(token.ToString(), d.Skip(2));
             if (d.Length > 2)
             {
                 Label label = newLabel(txt, Int32.Parse(d[0]), Int32.Parse(d[1]));
                 data.Add(label);
                 pContainer.Controls.Add(label);
             }
         }
         foreach (Label l in data)
         {
             l.Visible = true;
         }
         DrawingControl.ResumeDrawing(pContainer);
     }
     setSavedStatus(true);
 }
예제 #3
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
        private void Label_MouseDown(object sender, MouseEventArgs e)
        {
            Label l = (Label)sender;

            if (e.Button == MouseButtons.Left)
            {
                DrawingControl.SuspendDrawing(pContainer);
                l.BringToFront();
                iClickX = e.X;
                iClickY = e.Y;
                clicked = true;
                if (moveSelected && (bool)l.Tag)
                {
                    List <Label> selected = getListOfSelected();
                    Rectangle    bbox     = boundingBox(selected);
                    foreach (Label d in selected)
                    {
                        d.Visible = false;
                    }
                    selPanel.Location = bbox.Location;
                    selPanel.Size     = bbox.Size;
                    selPanel.SendToBack();
                    selPanel.Visible = true;
                }
                DrawingControl.ResumeDrawing(pContainer);
            }
            if (e.Button == MouseButtons.Right)
            {
                selectLabel(l, !(bool)l.Tag);
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
        private void duplicateSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <Label> itemsToDuplicate = new List <Label>();

            foreach (Label l in data)
            {
                if ((bool)l.Tag)
                {
                    itemsToDuplicate.Add(l);
                }
            }
            clearSelection(null, null);
            DrawingControl.SuspendDrawing(pContainer);
            foreach (Label l in itemsToDuplicate)
            {
                Label label = newLabel(l.Text, l.Left + globalGridSize / 2, l.Top + globalGridSize / 2);
                data.Add(label);
                pContainer.Controls.Add(label);
                selectLabel(label, true);
                label.BringToFront();
                label.Visible = true;
            }
            DrawingControl.ResumeDrawing(pContainer);
            setSavedStatus(false);
        }
예제 #5
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
        private void Label_MouseMove(object sender, MouseEventArgs e)
        {
            Label clickedLabel = (Label)sender;

            if (moveSelected && (bool)clickedLabel.Tag)
            {
                if (clicked && (e.Location != oldLocation))
                {
                    DrawingControl.SuspendDrawing(pContainer);
                    dragControl(selPanel, e);
                    foreach (Label l in data)
                    {
                        if ((bool)l.Tag)
                        {
                            dragControl(l, e);
                        }
                    }
                    DrawingControl.ResumeDrawing(pContainer);
                }
                oldLocation = e.Location;
            }
            else
            if (clicked)
            {
                dragControl(clickedLabel, e);
            }
        }
예제 #6
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
 private void gridAlignToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DrawingControl.SuspendDrawing(pContainer);
     foreach (Label l in data)
     {
         l.Left = (l.Left / globalGridSize) * globalGridSize;
         l.Top  = (l.Top / globalGridSize) * globalGridSize;
     }
     DrawingControl.ResumeDrawing(pContainer);
     setSavedStatus(false);
 }
예제 #7
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
 private void bigFontToolStripMenuItem_Click(object sender, EventArgs e)
 {
     bigFontToolStripMenuItem.Checked = !bigFontToolStripMenuItem.Checked;
     currentFontSize = bigFontToolStripMenuItem.Checked ? bigFontSize : smallFontSize;
     DrawingControl.SuspendDrawing(pContainer);
     foreach (Label l in data)
     {
         l.Font = new Font(fontName, currentFontSize);
     }
     DrawingControl.ResumeDrawing(pContainer);
 }
예제 #8
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
 private void clearAll()
 {
     DrawingControl.SuspendDrawing(pContainer);
     foreach (Label l in data)
     {
         pContainer.Controls.Remove(l);
         l.Dispose();
     }
     data.Clear();
     someSelection = false;
     setSavedStatus(false);
     DrawingControl.ResumeDrawing(pContainer);
 }
예제 #9
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
        private void pileSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <Label> dataToStack = getListOfSelected();
            Point        sOrigin     = new Point();

            sOrigin = boundingBox(dataToStack).Location;
            DrawingControl.SuspendDrawing(pContainer);
            foreach (Label l in dataToStack)
            {
                l.Location = sOrigin;
            }
            DrawingControl.ResumeDrawing(pContainer);
            setSavedStatus(false);
        }
예제 #10
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
 private void clearSelectedLabels(object sender, EventArgs e)
 {
     if (userIsSure("Do you really want to delete the selected items?"))
     {
         DrawingControl.SuspendDrawing(pContainer);
         List <Label> itemsToRemove = getListOfSelected();
         foreach (Label l in itemsToRemove)
         {
             pContainer.Controls.Remove(l);
             data.Remove(l);
             l.Dispose();
         }
         DrawingControl.ResumeDrawing(pContainer);
         someSelection = false;
         setSavedStatus(false);
     }
 }
예제 #11
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
        private void Label_MouseUp(object sender, MouseEventArgs e)
        {
            clicked = false;
            setSavedStatus(false);
            Label l = (Label)sender;

            if (moveSelected)
            {
                DrawingControl.SuspendDrawing(pContainer);
                foreach (Label d in data)
                {
                    d.Visible = true;
                }
                selPanel.Visible = false;
                DrawingControl.ResumeDrawing(pContainer);
            }
        }
예제 #12
0
파일: Form1.cs 프로젝트: Kuig/ScatterWords
 private void importText(string filename, Point cOrigin)
 {
     System.IO.Stream stream = File.OpenRead(filename);
     using (System.IO.StreamReader reader = new System.IO.StreamReader(stream))
     {
         if (selectOnimport)
         {
             clearSelection(null, null);
         }
         int prevDataLen = data.Count;
         DrawingControl.SuspendDrawing(pContainer);
         List <string> textData = new List <string>();
         foreach (Label l in data)
         {
             textData.Add(l.Text);
         }
         while (!reader.EndOfStream)
         {
             string txt = reader.ReadLine();
             if (!txt.Equals("") && (!skipDoubles || !textData.Contains(txt))) // .Contains is called only if strictly required
             {
                 Label label = newLabel(txt, 0, 0);
                 if (selectOnimport)
                 {
                     selectLabel(label, selectOnimport);
                 }
                 data.Add(label);
                 pContainer.Controls.Add(label);
             }
         }
         arrangeInColumns(data.Skip(prevDataLen), 2, cOrigin);
         foreach (Label l in data)
         {
             l.Visible = true;
         }
         DrawingControl.ResumeDrawing(pContainer);
     }
 }