public StatusWindow(StatusList statusList, Rectangle source, bool showAnyStatus)
 {
     _statusList       = statusList;
     _source           = source;
     _showAnyStatus    = showAnyStatus;
     _blackButtonStyle = Application.Current.Resources["BlackButton"] as Style;
     InitializeComponent();
 }
Ejemplo n.º 2
0
 public EditRule(Rule rule, StatusList statusList)
 {
     _rule       = rule;
     _statusList = statusList;
     InitializeComponent();
     InitializeCheckTextBox();
     InitializeCanvas();
 }
        public RuleSettingWindow(List <Rule> rules, StatusList status)
        {
            InitializeComponent();
            _rules  = rules;
            _status = status;

            _blackButtonStyle = Application.Current.Resources["BlackButton"] as Style;
            RefreshList();
        }
Ejemplo n.º 4
0
        public MainWindow()
        {
            _map    = new Map(10, 10);
            _rules  = new List <Rule>(0);
            _status = new StatusList();

            InitializeComponent();

            _dispatcherTimer.Tick    += dispatcherTimer_Tick;
            _dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            //_dispatcherTimer.Start();
        }
Ejemplo n.º 5
0
        public EditStatus(StatusList statusList, Status status)
        {
            _statusList = statusList;
            _status     = status;
            InitializeComponent();

            NameTextBox.Text = status.Description;
            RTextBox.Text    = status.DisplayColor.R.ToString();
            GTextBox.Text    = status.DisplayColor.G.ToString();
            BTextBox.Text    = status.DisplayColor.B.ToString();

            NameTextBox.TextChanged += NameTextBox_TextChanged;
            RTextBox.TextChanged    += RGBTextBox_TextChanged;
            GTextBox.TextChanged    += RGBTextBox_TextChanged;
            BTextBox.TextChanged    += RGBTextBox_TextChanged;
        }
Ejemplo n.º 6
0
        private void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Cellular Automaton Game File (*.cag)|*.cag";
            _rules  = new List <Rule>();
            _status = new StatusList(false);
            if (openFileDialog.ShowDialog() == true)
            {
                string[] allLines    = File.ReadAllLines(openFileDialog.FileName);
                int      mapLineLeft = 0;
                foreach (var line in allLines)
                {
                    string trim = line.Trim(' ', '\t');
                    if (trim.StartsWith("$"))
                    {
                        continue;
                    }
                    if (trim.Length == 0)
                    {
                        continue;
                    }

                    if (mapLineLeft > 0)
                    {
                        string[] split = trim.Split('#');
                        for (int j = 0; j < _map.Height; ++j)
                        {
                            _map[_map.Width - mapLineLeft, j] = int.Parse(split[j]);
                        }
                        --mapLineLeft;
                        if (mapLineLeft == 0)
                        {
                            ReconstructGrid();
                        }
                        continue;
                    }

                    if (trim.StartsWith("s"))
                    {
                        // Status Line
                        string[] split = trim.Split('#');

                        Status newStatus = new Status(split[1], Color.FromRgb(byte.Parse(split[2]), byte.Parse(split[3]), byte.Parse(split[4])));
                        _status.Add(newStatus);
                    }
                    else if (trim.StartsWith("r"))
                    {
                        // Rule Line
                        string[] split = trim.Split('#');

                        Rule newRule = new Rule(split[1], int.Parse(split[2]), int.Parse(split[3]), int.Parse(split[4]), int.Parse(split[5]), short.Parse(split[7]));
                        newRule.Result = int.Parse(split[6]);
                        int s = 8;
                        for (int i = -newRule.Left; i <= newRule.Right; ++i)
                        {
                            for (int j = -newRule.Top; j <= newRule.Bottom; ++j)
                            {
                                newRule[i, j] = int.Parse(split[s]);
                                ++s;
                            }
                        }

                        _rules.Add(newRule);
                    }
                    else if (trim.StartsWith("m"))
                    {
                        string[] split = trim.Split('#');

                        _map        = new Map(int.Parse(split[1]), int.Parse(split[2]), (Map.EdgeType) int.Parse(split[3]));
                        mapLineLeft = _map.Width;
                    }
                }
            }
            CalculateFitTransform();
            SetFixedTransforms();
            ResetTransforms();
        }