Ejemplo n.º 1
0
        static private void Shared(Struktura day, int temperature, int maxIndex)
        {
            if (temperature > 30)
            {
                day.Top[2]    = true;
                day.Bottom[1] = true;
                day.Shoes[1]  = true;
            }

            else if (temperature > 22)
            {
                day.Top[0]    = true;
                day.Bottom[1] = true;
                day.Shoes[1]  = true;
            }
            else if (temperature > 17)
            {
                day.Top[0]    = true;
                day.Bottom[0] = true;
                day.Shoes[1]  = true;
            }
            else if (temperature > 12)
            {
                day.Top[1]    = true;
                day.Bottom[0] = true;
                day.Shoes[1]  = true;
            }
            else
            {
                day.Top[1]    = true;
                day.Bottom[0] = true;
                day.Shoes[0]  = true;
            }
        }
Ejemplo n.º 2
0
        static private void CalculateAfternoon(Weather weather, Struktura value)
        {
            List <Hourly> hourly = weather.hourly;

            int[] weatherConditions = new int[3]; //0-chanceOfRain, 1-chanceOfSnow, 2-chanceOfSun
            int   chanceOfWindy     = 0;
            int   temperature       = 0;
            int   cloudy            = 0;

            for (int i = 4; i < 6; i++)
            {
                cloudy += Convert.ToInt32(hourly.ElementAt(i).cloudcover);
                weatherConditions[0] += Convert.ToInt32(hourly.ElementAt(i).chanceofrain);
                weatherConditions[1] += Convert.ToInt32(hourly.ElementAt(i).chanceofsnow);
                weatherConditions[2] += Convert.ToInt32(hourly.ElementAt(i).chanceofsunshine);
                chanceOfWindy        += Convert.ToInt32(hourly.ElementAt(i).chanceofwindy);
                temperature          += Convert.ToInt32(hourly.ElementAt(i).tempC);
            }
            cloudy             = (int)(cloudy / 2);
            value.Temperature  = temperature / 2;
            value.ChanceOfRain = weatherConditions[0] / 2;
            chanceOfWindy      = chanceOfWindy / 2;
            int max = Array.IndexOf(weatherConditions, weatherConditions.Max());

            CalculateAccessories(value, weatherConditions, chanceOfWindy, max, cloudy);
        }
Ejemplo n.º 3
0
        static private void CalculateNight(Weather weather, Struktura value)
        {
            List <Hourly> hourly = weather.hourly;

            int[] weatherConditions = new int[3]; //0-chanceOfRain, 1-chanceOfSnow, 2-chanceOfSun
            int   chanceOfWindy     = 0;
            int   temperature       = 0;
            int   i      = 6;
            int   cloudy = 0;

            while (i != 2)
            {
                cloudy += Convert.ToInt32(hourly.ElementAt(i).cloudcover);
                weatherConditions[0] += Convert.ToInt32(hourly.ElementAt(i).chanceofrain);
                weatherConditions[1] += Convert.ToInt32(hourly.ElementAt(i).chanceofsnow);
                weatherConditions[2] += Convert.ToInt32(hourly.ElementAt(i).chanceofsunshine);
                chanceOfWindy        += Convert.ToInt32(hourly.ElementAt(i).chanceofwindy);
                temperature          += Convert.ToInt32(hourly.ElementAt(i).tempC);
                i = (i + 1) % 8;
            }
            ;
            cloudy             = (int)(cloudy / 4);
            value.Temperature  = temperature / 4;
            value.ChanceOfRain = weatherConditions[0] / 4;
            chanceOfWindy      = chanceOfWindy / 4;
            int max = Array.IndexOf(weatherConditions, weatherConditions.Max());

            CalculateAccessories(value, weatherConditions, chanceOfWindy, max, cloudy);
            value.Accessories[0] = false;
        }
Ejemplo n.º 4
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog o = new OpenFileDialog
            {
                Filter = "XML Files (*.xml)|*.xml"
            };

            if (o.ShowDialog() == true)
            {
                struktura.Items.Clear();
                XmlSerializer deserializer = new XmlSerializer(typeof(Struktura));
                TextReader    reader       = new StreamReader(o.FileName);
                s = (Struktura)deserializer.Deserialize(reader);
                reader.Close();
                struktura.Items.Add(new TreeViewItem()
                {
                    Header = s.ime, HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                });
                if (s.programskiJezik != null && s.tip != null & s.ogrodje != null)
                {
                    if (s.programskiJezik.ToLower() == "c++")
                    {
                        if (s.tip.ToLower() == "console app")
                        {
                            struktura.Items.Add(new TreeViewItem()
                            {
                                Header = "Main.cpp", HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                            });
                        }
                    }
                    else if (s.programskiJezik.ToLower() == "c#")
                    {
                        if (s.tip.ToLower() == "wpf app")
                        {
                            struktura.Items.Add(new TreeViewItem()
                            {
                                Header = "MainWindow.cs", HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                            });
                            struktura.Items.Add(new TreeViewItem()
                            {
                                Header = "MainWindow.xaml", HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                            });
                            struktura.Items.Add(new TreeViewItem()
                            {
                                Header = "Settings.cs", HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                            });
                        }

                        else if (s.tip.ToLower() == "console app")
                        {
                            struktura.Items.Add(new TreeViewItem()
                            {
                                Header = "Main.cs", HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                            });
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            Graphics  g         = CreateGraphics();
            Bitmap    myBitmap  = new Bitmap(400, 400);
            Struktura strCenter = new Struktura();

            strCenter.x = 200; strCenter.y = 200; strCenter.z = 200;
            g.DrawLine(pen, new Point(150, 150), new Point(150, 250));
            Struktura[] poleStr = new Struktura[4];
            poleStr[0].x = 300; poleStr[0].y = 300; poleStr[0].z = 300;
            //Point3D pCenter = new Point3D(200, 200, 200);
            //Point3D p = new Point3D(150, 150, 150);
            Viewport3D view = new Viewport3D();
        }
Ejemplo n.º 6
0
        static private void CalculateAccessories(Struktura value, int[] weatherConditions, int chanceOfWindy, int max, int cloudy)
        {
            if (max == 0)
            {
                value.WeatherConditions[0] = true;
            }
            else if (max == 1)
            {
                value.WeatherConditions[1] = true;
            }
            else
            {
                value.WeatherConditions[2] = true;
            }

            if (chanceOfWindy >= 50)
            {
                value.Wind = true;
            }

            if (value.Temperature > 15)
            {
            }
            else if (value.Temperature > 7 && value.Temperature < 16)
            {
                value.Accessories[1] = true;
            }

            else if (value.Temperature > -1 && value.Temperature < 7)
            {
                value.Accessories[2] = true;
            }
            else
            {
                value.Accessories[2] = true;
                value.Accessories[3] = true;
                value.Accessories[4] = true;
            }


            if (value.WeatherConditions[2] && (cloudy <= 55))
            {
                value.Accessories[0] = true; //Sunglasses
            }

            if ((value.Temperature < 2) || (value.Temperature < 5 && chanceOfWindy >= 75))
            {
                value.Accessories[5] = true; //Scarf
            }
        }
Ejemplo n.º 7
0
        private Struktura Create(EventStrukturaCreated evt)
        {
            var model = new Struktura()
            {
                Generation       = evt.Generation,
                EventGuid        = evt.EventId,
                StrukturaId      = evt.StrukturaId,
                DatumAktualizace = DateTime.Now,
                Nazev            = evt.Nazev,
                SoucastId        = evt.SoucastId,
                Clenove          = evt.Clenove,
                Zkratka          = evt.Zkratka,
            };

            return(model);
        }
Ejemplo n.º 8
0
        public async Task DeleteStruktura(Struktura struktura)
        {
            var childs = db.Struktury.Where(c => c.ParentStrukturaId == struktura.StrukturaId);

            foreach (var item in childs)
            {
                await DeleteStruktura(item);
            }

            var ev = new EventStrukturaRemoved()
            {
                EventId     = Guid.NewGuid(),
                StrukturaId = struktura.StrukturaId,
                Generation  = struktura.Generation + 1
            };
            await _handler.PublishEvent(ev, MessageType.StrukturaRemoved, ev.EventId, null, ev.Generation, struktura.StrukturaId);

            db.Struktury.Remove(struktura);
        }
Ejemplo n.º 9
0
        static private void CalculateAccessories(Struktura value, int[] weatherConditions, int chanceOfWindy, int max)
        {
            if (max == 0)
            {
                value.WeatherConditions[0] = true;
            }
            else if (max == 1)
            {
                value.WeatherConditions[1] = true;
            }
            else
            {
                value.WeatherConditions[2] = true;
            }

            if (chanceOfWindy >= 50)
            {
                value.Wind = true;
            }

            if (value.Temperature > 22)
            {
                if (value.WeatherConditions[2])
                {
                    value.Accessories[0] = true;
                }
            }
            else if (value.Temperature > 10)
            {
                value.Accessories[1] = true;
            }
            else
            {
                value.Accessories[2] = true;
                value.Accessories[3] = true;
                value.Accessories[4] = true;
            }
        }
Ejemplo n.º 10
0
        private void Save(object sender, RoutedEventArgs e)
        {
            Struktura s = new Struktura();

            string[] files;
            string   path = Directory.GetCurrentDirectory();

            files = Directory.GetFiles(path);
            string         fileName       = txtBox.Text;
            var            jezik          = (ProgramskiJezik)programskiJezik.SelectedValue;
            string         tip            = (string)tipi.SelectedValue;
            var            ogrodje        = (Ogrodje)ogrodja.SelectedValue;
            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                InitialDirectory = path,
                Filter           = "XML Files (*.XML)|*.XML",
                FileName         = fileName
            };
            DialogResult fbd = saveFileDialog.ShowDialog();

            if (fbd == System.Windows.Forms.DialogResult.OK)
            {
                ((MainWindow)System.Windows.Application.Current.MainWindow).s = s;
                s.ime             = fileName;
                s.programskiJezik = jezik.Name.ToLower();
                s.tip             = tip.ToLower();
                s.ogrodje         = ogrodje.Name.ToLower();
                XmlSerializer serializer = new XmlSerializer(typeof(Struktura));
                TextWriter    writer     = new StreamWriter(saveFileDialog.FileName);
                serializer.Serialize(writer, s);
                writer.Close();
                ((MainWindow)System.Windows.Application.Current.MainWindow).struktura.Items.Clear();
                //File.WriteAllText(saveFileDialog.FileName, "Datoteka");
                ((MainWindow)System.Windows.Application.Current.MainWindow).struktura.Items.Add(new TreeViewItem()
                {
                    Header = fileName, HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                });
                if (jezik != null && tip != null & ogrodje != null)
                {
                    if (jezik.Name.ToLower() == "c++")
                    {
                        if (tip.ToLower() == "console app")
                        {
                            ((MainWindow)System.Windows.Application.Current.MainWindow).struktura.Items.Add(new TreeViewItem()
                            {
                                Header = "Main.cpp", HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                            });
                        }
                    }
                    else if (jezik.Name.ToLower() == "c#")
                    {
                        if (tip.ToLower() == "wpf app")
                        {
                            ((MainWindow)System.Windows.Application.Current.MainWindow).struktura.Items.Add(new TreeViewItem()
                            {
                                Header = "MainWindow.cs", HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                            });
                            ((MainWindow)System.Windows.Application.Current.MainWindow).struktura.Items.Add(new TreeViewItem()
                            {
                                Header = "MainWindow.xaml", HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                            });
                            ((MainWindow)System.Windows.Application.Current.MainWindow).struktura.Items.Add(new TreeViewItem()
                            {
                                Header = "Settings.cs", HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                            });
                        }

                        else if (tip.ToLower() == "console app")
                        {
                            ((MainWindow)System.Windows.Application.Current.MainWindow).struktura.Items.Add(new TreeViewItem()
                            {
                                Header = "Main.cs", HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch
                            });
                        }
                    }
                    this.Close();
                }
            }
        }
Ejemplo n.º 11
0
        private Struktura Modify(EventStrukturaUpdated evt, Struktura item)
        {
            item.EventGuid = evt.EventId;

            return(item);
        }