Ejemplo n.º 1
0
        private void Color_Edit(object sender, RoutedEventArgs e)
        {
            DominoColor  color = (DominoColor)((Button)sender).DataContext;
            ColorControl c     = new ColorControl();

            c.ColorPicker.SelectedColor = color.rgb;
            c.count = color.count;
            c.name  = color.name;
            c.ShowDialog();
            if (c.DialogResult == true)
            {
                color.rgb   = c.ColorPicker.SelectedColor;
                color.name  = c.name;
                color.count = c.count;
            }
            DependencyObject parent = VisualTreeHelper.GetParent(sender as DependencyObject);

            while (!(parent is ListView))
            {
                parent = VisualTreeHelper.GetParent(parent as DependencyObject);
            }
            List <DominoColor> colors = ((ListView)parent).ItemsSource as List <DominoColor>;

            (parent as ListView).Items.Refresh();
        }
Ejemplo n.º 2
0
        private void ListView_KeyDown(object sender, KeyEventArgs e)
        {
            ListView           lvColors = (ListView)sender;
            List <DominoColor> colors   = (lvColors.DataContext as ColorArrayDocument).cols;

            int index = lvColors.SelectedIndex;

            if (e.Key == Key.CapsLock)
            {
                if (index > 0)
                {
                    DominoColor temp = colors[index - 1];
                    colors[index - 1] = colors[index];
                    colors[index]     = temp;
                    lvColors.Items.Refresh();
                    lvColors.SelectedIndex = --index;
                    lvColors.ScrollIntoView(lvColors.Items.GetItemAt(index));
                }
            }
            if (e.Key == Key.LeftShift)
            {
                if (index < colors.Count - 1)
                {
                    DominoColor temp = colors[index + 1];
                    colors[index + 1] = colors[index];
                    colors[index]     = temp;
                    lvColors.Items.Refresh();
                    lvColors.SelectedIndex = ++index;
                    lvColors.ScrollIntoView(lvColors.Items.GetItemAt(index));
                }
            }
        }
Ejemplo n.º 3
0
        private String ParseRegex(DominoColor dc, int count)
        {
            string s = "";

            for (int i = 0; i < m_text_regex.Length; i++)
            {
                if (m_text_regex[i] == '%')
                {
                    string substring = "";
                    try
                    {
                        substring = m_text_regex.Substring(i + 1, m_text_regex.IndexOf('%', i + 1) - i - 1);
                    }
                    catch
                    {
                    }
                    if (substring.ToLower() == "color")
                    {
                        s += dc.name;
                    }
                    else if (substring.ToLower() == "count")
                    {
                        s += count;
                    }
                    i = (m_text_regex.IndexOf('%', i + 1) == -1) ? i : m_text_regex.IndexOf('%', i + 1);
                }
                else
                {
                    s += m_text_regex[i];
                }
            }
            return(s);
        }
Ejemplo n.º 4
0
 public void changeCurrentColor()
 {
     this.dominoColor = (DominoColor)((int)this.dominoColor + 1);
     if (this.dominoColor >= DominoColor.nColors)
     {
         this.dominoColor = (DominoColor)0;
     }
 }
Ejemplo n.º 5
0
 public void changeCurrentColor()
 {
     this.dominoColor = (DominoColor)((int)this.dominoColor + 1);
     if (this.dominoColor >= DominoColor.nColors)
     {
         this.dominoColor = (DominoColor)0;
     }
 }
        private List <DominoColor> CloneDominoColors(List <DominoColor> source)
        {
            List <DominoColor> result = new List <DominoColor>();

            foreach (DominoColor d in source)
            {
                DominoColor dom = new DominoColor()
                {
                    count = d.count, name = d.name, rgb = d.rgb, used_in_projects = d.used_in_projects
                };
                result.Add(dom);
            }
            return(result);
        }
Ejemplo n.º 7
0
        private void Color_Delete(object sender, RoutedEventArgs e)
        {
            DominoColor      color  = (DominoColor)((Button)sender).DataContext;
            DependencyObject parent = VisualTreeHelper.GetParent(sender as DependencyObject);

            while (!(parent is ListView))
            {
                parent = VisualTreeHelper.GetParent(parent as DependencyObject);
            }
            List <DominoColor> colors = ((ListView)parent).ItemsSource as List <DominoColor>;

            colors.Remove(color);
            (parent as ListView).Items.Refresh();
        }
        private void Color_Edit(object sender, RoutedEventArgs e)
        {
            DominoColor  color = (DominoColor)((Button)sender).DataContext;
            ColorControl c     = new ColorControl();

            c.ColorPicker.SelectedColor = color.rgb;
            c.count     = color.count;
            c.name      = color.name;
            c.ColorOnly = true;
            c.ShowDialog();
            if (c.DialogResult == true)
            {
                color.rgb   = c.ColorPicker.SelectedColor;
                color.name  = c.name;
                color.count = c.count;
            }
            temp.Colors[color.used_in_projects[0]] = color;
            lvColors.Items.Refresh();
        }
Ejemplo n.º 9
0
        public override void Apply()
        {
            if (added == null)
            {
                var color = new DominoColor(Avalonia.Media.Colors.IndianRed, 0, _("New Color"));

                repo.Add(color, index);
                added = new ColorListEntry()
                {
                    DominoColor  = color,
                    SortIndex    = repo.Anzeigeindizes[repo.IndexOf(color)],
                    ProjectCount = new ObservableCollection <int>(Enumerable.Repeat(0, _ColorList[0].ProjectCount.Count))
                };
                _ColorList.Add(added);
            }
            else
            {
                // redo
                added.Deleted = false;
            }
        }
Ejemplo n.º 10
0
        private void Color_MoveDown(object sender, RoutedEventArgs e)
        {
            DominoColor      color  = (DominoColor)((Button)sender).DataContext;
            DependencyObject parent = VisualTreeHelper.GetParent(sender as DependencyObject);

            while (!(parent is ListView))
            {
                parent = VisualTreeHelper.GetParent(parent as DependencyObject);
            }
            List <DominoColor> colors = ((ListView)parent).ItemsSource as List <DominoColor>;
            int index = colors.IndexOf(color);

            if (index < colors.Count - 1)
            {
                DominoColor temp = colors[index + 1];
                colors[index + 1] = color;
                colors[index]     = temp;
                (parent as ListView).Items.Refresh();
                (parent as ListView).SelectedIndex = ++index;
                (parent as ListView).ScrollIntoView((parent as ListView).Items.GetItemAt(index));
            }
        }
Ejemplo n.º 11
0
        private void AddColor(object sender, RoutedEventArgs e)
        {
            DependencyObject parent = VisualTreeHelper.GetParent(sender as DependencyObject);

            parent = VisualTreeHelper.GetChild(parent, 0);
            List <DominoColor> colors = ((ListView)parent).ItemsSource as List <DominoColor>;
            DominoColor        color  = new DominoColor("New Color", Color.FromRgb(0, 0, 0), 1000);
            ColorControl       c      = new ColorControl();

            c.ColorPicker.SelectedColor = color.rgb;
            c.count = color.count;
            c.name  = color.name;
            c.ShowDialog();
            if (c.DialogResult == true)
            {
                color.rgb   = c.ColorPicker.SelectedColor;
                color.name  = c.name;
                color.count = c.count;
            }
            colors.Add(color);
            (parent as ListView).Items.Refresh();
            (parent as ListView).ScrollIntoView((parent as ListView).Items.GetItemAt(colors.Count - 1));
        }
Ejemplo n.º 12
0
 public MoveColorOperation(ColorRepository repo, DominoColor stoneToMove, bool up)
 {
     this.repo        = repo;
     this.stoneToMove = stoneToMove;
     this.up          = up;
 }
Ejemplo n.º 13
0
        public static FieldPlanHelper CalculateFieldplan(FieldDocument BaseDoc, int TemplateLength, bool?reverse = false)
        {
            int[,] dominoes = BaseDoc.dominoes;
            if (BaseDoc.horizontal == false)
            {
                // if direction = vertical, then translate the field
                dominoes = new int[dominoes.GetLength(1), dominoes.GetLength(0)];
                for (int i = 0; i < dominoes.GetLength(0); i++)
                {
                    for (int j = 0; j < dominoes.GetLength(1); j++)
                    {
                        dominoes[i, j] = BaseDoc.dominoes[j, dominoes.GetLength(0) - 1 - i];
                    }
                }
            }
            int[,] tempdominoes = dominoes;
            if (reverse == true)
            {
                // if reversed building direction
                dominoes = new int[dominoes.GetLength(0), dominoes.GetLength(1)];
                for (int i = 0; i < dominoes.GetLength(0); i++)
                {
                    for (int j = 0; j < dominoes.GetLength(1); j++)
                    {
                        dominoes[i, j] = tempdominoes[dominoes.GetLength(0) - i - 1, dominoes.GetLength(1) - j - 1];
                    }
                }
            }
            int             blocks = (int)Math.Ceiling((double)((double)dominoes.GetLength(0) / (double)TemplateLength));
            FieldPlanHelper b      = new FieldPlanHelper();

            b.counts = new int[dominoes.GetLength(1), blocks][];
            b.colors = new DominoColor[dominoes.GetLength(1), blocks][];

            for (int i = 0; i < b.counts.GetLength(0); i++)     // foreach line
            {
                for (int j = 0; j < b.counts.GetLength(1); j++) // foreach block in this line
                {
                    int                initial_x     = j * TemplateLength;
                    int                pos_x         = 0;
                    int                currentcount  = 0;
                    DominoColor        currentColor  = null;
                    List <DominoColor> currentColors = new List <DominoColor>();
                    List <int>         currentCounts = new List <int>();
                    while (pos_x < TemplateLength && (initial_x + pos_x) < dominoes.GetLength(0))
                    {
                        if (dominoes[initial_x + pos_x, i] != -1 && BaseDoc.Colors[dominoes[initial_x + pos_x, i]] == currentColor)
                        {
                            currentcount++;
                        }
                        else
                        {
                            if (currentColor != null)
                            {
                                currentColors.Add(currentColor);
                                currentCounts.Add(currentcount);
                            }

                            currentcount = 1;
                            currentColor = (dominoes[initial_x + pos_x, i] == -1) ? null : BaseDoc.Colors[dominoes[initial_x + pos_x, i]];
                        }
                        pos_x++;
                    }
                    currentColors.Add(currentColor);
                    currentCounts.Add(currentcount);
                    b.colors[i, j] = currentColors.ToArray();
                    b.counts[i, j] = currentCounts.ToArray();
                }
            }
            int numberofcolumns = 0;

            for (int i = 0; i < b.colors.GetLength(0); i++)
            {
                int tempnum = 0;
                // get the number of cells for each line
                for (int j = 0; j < b.colors.GetLength(1); j++)
                {
                    tempnum += b.colors[i, j].Length;
                }
                if (tempnum > numberofcolumns)
                {
                    numberofcolumns = tempnum;
                }
            }
            b.cellcount = numberofcolumns;
            return(b);
        }