Пример #1
0
    /// <summary>
    /// Create a populated instance of the given type
    /// </summary>
    /// <typeparam name="T">The type to be created</typeparam>
    /// <returns>Populated instance of the given type</returns>
    public T Create <T>()
    {
        var instance   = Activator.CreateInstance(typeof(T));
        var properties = instance.GetType().GetProperties();

        foreach (var property in properties)
        {
            if (!IgnoreProperty <T>(property))
            {
                if (FixedValues.Any(f => f.Type == typeof(T) && f.PropertyName.ToLower() == property.Name.ToLower()))
                {
                    var fixedValue = FixedValues.Single(f => f.Type == typeof(T) && f.PropertyName.ToLower() == property.Name.ToLower());
                    property.SetValue(instance, fixedValue.Value);
                }
                else
                {
                    SetRandomPropertyValue(property, instance);
                }
            }
        }

        if (LogToConsole)
        {
            Console.WriteLine($"Datr object type {typeof(T).Name} created:");
            Console.WriteLine(JsonSerializer.Serialize(instance));
        }

        return((T)instance);
    }
Пример #2
0
 public MainWindow()
 {
     InitializeComponent();
     configuration.SettingsSaved += Configuration_SettingsSaved;
     FixedValues.InitializeReader();
     SkinCreationWizard.Instance.SetMasterViewModel(DataContext as OsmoViewModel);
     TemplateManager.Instance.SetMasterViewModel(DataContext as OsmoViewModel);
 }
Пример #3
0
        private double GetMinValue()
        {
            double min1 = double.MaxValue, min2 = double.MaxValue;

            if (FixedValues != null)
            {
                min1 = FixedValues.Min(pair => pair.Value);
            }
            if (PredictedValues != null)
            {
                min2 = PredictedValues.Min(pair => pair.Value);
            }
            return(min1 < min2 ? min1 : min2);
        }
Пример #4
0
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            string cmdstr = "select user_name, profile_pic from PINTEREST_USER where user_id=:id";

            ProfileDataAdapter = new OracleDataAdapter(cmdstr, FixedValues.ordb);
            ProfileDataAdapter.SelectCommand.Parameters.Add("id", OtherUserID);

            ProfileDataSet = new DataSet();
            ProfileDataAdapter.Fill(ProfileDataSet);
            ProfileName_label.Content = ProfileDataSet.Tables[0].Rows[0][0];
            byte[] image = (byte[])ProfileDataSet.Tables[0].Rows[0][1];
            ProfilePic.Fill = new ImageBrush(FixedValues.LoadImage(image));

            cmdstr             = "select count(*) from user_following where user_id = :userid";
            ProfileDataAdapter = new OracleDataAdapter(cmdstr, FixedValues.ordb);
            ProfileDataAdapter.SelectCommand.Parameters.Add("userid", OtherUserID);
            ProfileDataSet = new DataSet();
            ProfileDataAdapter.Fill(ProfileDataSet);

            ProfileFollowers_label.Content = ProfileDataSet.Tables[0].Rows[0][0];
        }
Пример #5
0
        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            string cmdstr = "select user_name, profile_pic from PINTEREST_USER where user_id=:id";

            ProfileDataAdapter = new OracleDataAdapter(cmdstr, FixedValues.ordb);
            ProfileDataAdapter.SelectCommand.Parameters.Add("id", Account.UserID);
            ProfileDataSet = new DataSet();
            ProfileDataAdapter.Fill(ProfileDataSet);
            ProfileName.Content = ProfileDataSet.Tables[0].Rows[0][0];
            byte[] image = (byte[])ProfileDataSet.Tables[0].Rows[0][1];

            BitmapImage ProfileImage = FixedValues.LoadImage(image);

            ProfilePic.Fill = new ImageBrush(ProfileImage);

            con.Open();
            OracleCommand command = new OracleCommand();

            command.Connection  = con;
            command.CommandText = "select count(*) from user_following where user_following = :userid ";
            command.CommandType = CommandType.Text;
            command.Parameters.Add("userid", Account.UserID);
            OracleDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                num_Followers.Content = reader[0].ToString();
            }
            command             = new OracleCommand();
            command.Connection  = con;
            command.CommandText = "select count(*) from user_following where user_id = :userid ";
            command.CommandType = CommandType.Text;
            command.Parameters.Add("userid", Account.UserID);
            reader = command.ExecuteReader();
            if (reader.Read())
            {
                num_Following.Content = reader[0].ToString();
            }
            reader.Close();
        }
Пример #6
0
 private SkinSelect()
 {
     InitializeComponent();
     FixedValues.InitializeReader();
     SkinManager.Instance.EmptySkinItemAdded += SkinManager_EmptySkinItemAdded;
 }
Пример #7
0
 private SkinSelect()
 {
     InitializeComponent();
     FixedValues.InitializeReader();
 }
Пример #8
0
        private void Pins_btn_Click(object sender, RoutedEventArgs e)
        {
            con.Open();
            boardPanel.Children.Clear();

            OracleCommand command = new OracleCommand();

            command.Connection  = con;
            command.CommandText = "select pin_name, pin_image, pin_id from pin  where user_id= :userid ";
            command.CommandType = CommandType.Text;
            command.Parameters.Add("userid", Account.UserID);
            OracleDataReader reader = command.ExecuteReader();

            //initial coordinates... don't change
            double initLeft   = 40;
            double initTop    = 10;
            double initRight  = 510;
            double initBottom = 10;

            //for first login only.. don't change
            double d;
            int    i = 0;

            while (reader.Read())
            {
                if ((i + 1) % 5 == 0)
                {
                    initLeft  = 20;
                    initRight = 510;
                    i         = 0;
                }

                if (i >= 1)
                {
                    d = 0.5;
                }

                else
                {
                    d = i;
                }


                Pinterest_V2.UserControls.myPinUserControl myPinsControl = new UserControls.myPinUserControl(boardPanel);

                myPinsControl.myPinButton.Content = reader[0];
                byte[] image = (byte[])reader[1];
                myPinsControl.myPinButton.Background = new ImageBrush(FixedValues.LoadImage(image));

                myPinsControl.myPinButton.Foreground          = Brushes.White;
                myPinsControl.moveIcon.Foreground             = Brushes.White;
                myPinsControl.DeleteMyPin_btn_Icon.Foreground = Brushes.White;
                myPinsControl.EditMyPin_Icon.Foreground       = Brushes.White;
                myPinsControl.pin_id = Convert.ToInt32(reader[2]);

                myPinsControl.Margin = new Thickness(initLeft + (i * 230), initTop - (d * 440), initRight - (i * 220), initBottom - 220 * d);
                boardPanel.Children.Add(myPinsControl);

                i++;
            }

            reader.Close();
            con.Close();
        }
Пример #9
0
        private void Board_btn_Click(object sender, RoutedEventArgs e)
        {
            con.Open();
            boardPanel.Children.Clear();

            OracleCommand BoardCommand = new OracleCommand();

            BoardCommand.Connection  = con;
            BoardCommand.CommandText = "select board_name from board where user_id= :userid ";
            BoardCommand.CommandType = CommandType.Text;
            BoardCommand.Parameters.Add("userid", Account.UserID);
            OracleDataReader BoardReader = BoardCommand.ExecuteReader();

            string picName = FixedValues.getCurrentPath() + "images\\empty.png";

            //initial coordinates... don't change
            double initLeft   = 0;
            double initTop    = 10;
            double initRight  = 670;
            double initBottom = 10;

            double d;
            int    i = 0;

            while (BoardReader.Read())
            {
                if ((i + 1) % 5 == 0)
                {
                    initLeft  = 0;
                    initRight = 670;
                    i         = 0;
                }

                if (i >= 2)
                {
                    d = 1;
                }

                else
                {
                    d = i;
                }


                OracleCommand PinCommand = new OracleCommand();
                PinCommand.Connection = con;

                PinCommand.CommandText = "select pin_image from pin  where board_name= :boardname and user_id= :userid ";
                PinCommand.CommandType = CommandType.Text;
                PinCommand.Parameters.Add("boardname", BoardReader[0].ToString());
                PinCommand.Parameters.Add("userid", Account.UserID);
                OracleDataReader PinReader = PinCommand.ExecuteReader();

                BitmapImage BoardImage;
                if (PinReader.Read())
                {
                    byte[] image = (byte[])PinReader[0];
                    BoardImage = FixedValues.LoadImage(image);
                }
                else
                {
                    BoardImage = new BitmapImage(new Uri(picName, UriKind.Relative));
                }
                PinReader.Close();


                Pinterest_V2.UserControls.boardUserControl boardsControl = new UserControls.boardUserControl(boardPanel);

                boardsControl.boardButton.Content = BoardReader[0];

                boardsControl.boardButton.Background            = new ImageBrush(BoardImage);
                boardsControl.boardButton.Foreground            = Brushes.White;
                boardsControl.DeleteMyBoard_btn_Icon.Foreground = Brushes.White;
                boardsControl.EditMyBoard_Icon.Foreground       = Brushes.White;

                boardsControl.Margin = new Thickness(initLeft + (i * 230), initTop - (d * 440), initRight - (i * 220), initBottom - 220 * d);
                boardPanel.Children.Add(boardsControl);
                i++;
            }

            BoardReader.Close();
            con.Close();
        }