Beispiel #1
0
            /**
            * Constructor
            */
			public ListViewItem()
			{
                mGrid = new System.Windows.Controls.Grid();

				mIcon = new System.Windows.Controls.Image();
				mIcon.VerticalAlignment = VerticalAlignment.Center;
				mStretch = new System.Windows.Media.Stretch();

				mText = new System.Windows.Controls.TextBlock();
				mText.TextWrapping = TextWrapping.NoWrap;
				mText.Margin = new Thickness(10);
				mText.VerticalAlignment = VerticalAlignment.Center;
				mText.TextAlignment = TextAlignment.Left;

				mColumn1 = new ColumnDefinition();
				mColumn1.Width = new GridLength(1, GridUnitType.Auto);

				mColumn2 = new ColumnDefinition();
				mColumn2.Width = new GridLength(1, GridUnitType.Star);

				mRow = new RowDefinition();
				mRow.Height = new GridLength(1, GridUnitType.Auto);

				mGrid.RowDefinitions.Add(mRow);
				mGrid.ColumnDefinitions.Add(mColumn1);
				mGrid.ColumnDefinitions.Add(mColumn2);

				Grid.SetRow(mIcon, 0);
				Grid.SetColumn(mIcon, 0);

				Grid.SetRow(mText, 0);
				Grid.SetColumnSpan(mText, 1);
				Grid.SetColumn(mText, 1);

				mGrid.Children.Add(mIcon);
				mGrid.Children.Add(mText);

                View = mGrid;

                this.ItemSelected = false;
                this.ItemsSourceItemIndex = -1;

                // set the default font color values
                mFontColor = new SolidColorBrush(Colors.White);
                mSubtitleFontColor = new SolidColorBrush(Colors.White);
			}
Beispiel #2
0
            /**
             * Constructor
             */
            public ListViewItem()
            {
                mGrid = new System.Windows.Controls.Grid();

                mIcon = new System.Windows.Controls.Image();
                mIcon.VerticalAlignment = VerticalAlignment.Center;
                mStretch = new System.Windows.Media.Stretch();

                mText = new System.Windows.Controls.TextBlock();
                mText.TextWrapping      = TextWrapping.NoWrap;
                mText.Margin            = new Thickness(10);
                mText.VerticalAlignment = VerticalAlignment.Center;
                mText.TextAlignment     = TextAlignment.Left;

                mColumn1       = new ColumnDefinition();
                mColumn1.Width = new GridLength(1, GridUnitType.Auto);

                mColumn2       = new ColumnDefinition();
                mColumn2.Width = new GridLength(1, GridUnitType.Star);

                mRow        = new RowDefinition();
                mRow.Height = new GridLength(1, GridUnitType.Auto);

                mGrid.RowDefinitions.Add(mRow);
                mGrid.ColumnDefinitions.Add(mColumn1);
                mGrid.ColumnDefinitions.Add(mColumn2);

                Grid.SetRow(mIcon, 0);
                Grid.SetColumn(mIcon, 0);

                Grid.SetRow(mText, 0);
                Grid.SetColumnSpan(mText, 1);
                Grid.SetColumn(mText, 1);

                mGrid.Children.Add(mIcon);
                mGrid.Children.Add(mText);

                mView = mGrid;
            }
Beispiel #3
0
        /// <summary>
        /// Handler for the OnStartup event.
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">Event args.</param>
        public virtual void OnStartup(object sender, StartupEventArgs e)
        {
            String strInitValue;
            if (e.InitParams.TryGetValue("playlist", out strInitValue))
            {
                try
                {
                    Playlist.Clear();
                    Playlist.ParseXml(HtmlPage.Document.DocumentUri, strInitValue);
                }
                catch (System.Xml.XmlException xe)
                {
                    Debug.WriteLine("XML Parsing Error:" + xe.ToString());
                }
                catch (NullReferenceException)
                {
                }

                if (e.InitParams.TryGetValue("autoplay", out strInitValue))
                {
                    try
                    {
                        m_autoPlayCache = Convert.ToBoolean(strInitValue, CultureInfo.CurrentCulture);
                    }
                    catch (System.FormatException)
                    {
                        m_autoPlayCache = true;
                    }
                }
                else
                {
                    m_autoPlayCache = true; // fake/preview mode
                }

                if (e.InitParams.TryGetValue("autoload", out strInitValue))
                {
                    try
                    {
                        m_autoLoadCache = Convert.ToBoolean(strInitValue, CultureInfo.CurrentCulture);
                    }
                    catch (System.FormatException)
                    {
                        m_autoLoadCache = true;
                    }
                }
                else
                {
                    m_autoLoadCache = true; // fake/preview mode
                }

                if (e.InitParams.TryGetValue("muted", out strInitValue))
                {
                    try
                    {
                        m_mutedCache = Convert.ToBoolean(strInitValue, CultureInfo.CurrentCulture);
                    }
                    catch (System.FormatException)
                    {
                        m_mutedCache = false;
                    }
                }
                else
                {
                    m_mutedCache = true; // fake/preview mode
                }

                if (e.InitParams.TryGetValue("stretchmode", out strInitValue))
                {
                    int stretchMode = 0;
                    try
                    {
                        stretchMode = Convert.ToInt32(strInitValue, CultureInfo.CurrentCulture);
                    }
                    catch (System.FormatException)
                    {
                        stretchMode = 0;
                    }

                    switch (stretchMode)
                    {
                        default:
                        case 0:
                            m_stretchMode = Stretch.None;
                            break;
                        case 1:
                            m_stretchMode = Stretch.Uniform;
                            break;
                        case 2:
                            m_stretchMode = Stretch.UniformToFill;
                            break;
                        case 3:
                            m_stretchMode = Stretch.Fill;
                            break;
                    }
                }

                if (e.InitParams.TryGetValue("background", out strInitValue))
                {
                    try
                    {
                        UserBackgroundColor = new SolidColorBrush(ColorFromString(strInitValue));
                    }
                    catch (System.FormatException)
                    {
                        UserBackgroundColor = new SolidColorBrush(ColorFromString("#FF0000FF"));
                    }
                }

                if (e.InitParams.TryGetValue("displaytimecode", out strInitValue))
                {
                    try
                    {
                        DisplayTimeCode = bool.Parse(strInitValue);
                    }
                    catch (System.FormatException)
                    {
                        DisplayTimeCode = false;
                    }
                }

                if (e.InitParams.TryGetValue("enablecaptions", out strInitValue))
                {
                    try
                    {
                        SetCaptionsButtonVisibility(bool.Parse(strInitValue) ? Visibility.Visible : Visibility.Collapsed);
                    }
                    catch (System.FormatException)
                    {
                        SetCaptionsButtonVisibility(Visibility.Visible);
                    }

                    CaptionsVisibility = CaptionsButtonVisibility;
                }
            }
        }
 public void setMediaSource(string filepath, System.Windows.Media.Stretch displaymode) // Set the source (path) of media element
 {
     mediaelement1.Source  = new Uri(filepath);                                        // Set the element Source
     mediaelement1.Stretch = displaymode;                                              // Element Box size
     New_emediaEnded       = false;
 }
Beispiel #5
0
        private void LoadConfig()
        {
            string configFile = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Moe_config.ini";

            //读取配置文件
            if (System.IO.File.Exists(configFile))
            {
                try
                {
                    string[] lines = System.IO.File.ReadAllLines(configFile);
                    downloadC.NumOnce = Int32.Parse(lines[0]);
                    if (lines[1] != "." && System.IO.Directory.Exists(lines[1]))
                        DownloadControl.SaveLocation = lines[1];

                    if (lines[2].Contains(';'))
                    {
                        string[] parts = lines[2].Split(';');
                        //itmJpg.IsChecked = parts[0].Equals("1");
                        addressType = (AddressType)Enum.Parse(typeof(AddressType), parts[0]);

                        if (parts[1] == "1")
                        {
                            //GlassHelper.noBlur = false;
                        }

                        if (parts.Length > 2)
                        {
                            numOfLoading = Int32.Parse(parts[2]);
                            if (numOfLoading < 4) numOfLoading = 5;
                        }
                        if (parts.Length > 3)
                        {
                            itmMaskViewed.IsChecked = parts[3].Equals("1");
                        }
                        if (parts.Length > 4)
                        {
                            string[] words = parts[4].Split('|');
                            foreach (string word in words)
                            {
                                //if (word.Trim().Length > 0)
                                //txtSearch.Items.Add(word);
                                searchControl.AddUsedItem(word);
                            }
                        }
                        //if (!txtSearch.Items.Contains("thighhighs"))
                        //txtSearch.Items.Add("thighhighs");
                        if (parts.Length > 5)
                        {
                            Proxy = parts[5];
                        }
                        if (parts.Length > 6)
                        {
                            bossKey = (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), parts[6]);
                        }
                        if (parts.Length > 7)
                        {
                            itmSmallPre.IsChecked = parts[7].Equals("1");
                        }
                        if (parts.Length > 8)
                        {
                            ProxyType = (ProxyType)Enum.Parse(typeof(ProxyType), parts[8]);
                        }
                        if (parts.Length > 9)
                        {
                            try
                            {
                                //Size pos = Size.Parse(parts[9]);
                                var posItem = parts[9].Split(',');
                                Size pos = new Size(int.Parse(posItem[0]), int.Parse(posItem[1]));
                                if (pos.Width > MinWidth && pos.Height > MinHeight)
                                {
                                    //rememberPos = true;
                                    //Left = pos.X;
                                    //Top = pos.Y;
                                    //startPos.Width = pos.Width;
                                    //startPos.Height = pos.Height;
                                    Width = pos.Width;
                                    Height = pos.Height;
                                }
                            }
                            catch { }
                        }
                        if (parts.Length > 10)
                        {
                            togglePram.IsChecked = parts[10].Equals("1");
                            if (togglePram.IsChecked.Value)
                            {
                                //grdParam.Width = 0;
                                //grdParam.Opacity = 0;
                            }
                            else
                            {
                                grdParam.Width = 479;
                                grdParam.Opacity = 1;
                            }
                        }
                        if (parts.Length > 11)
                        {
                            PreFetcher.CachedImgCount = int.Parse(parts[11]);
                        }
                        if (parts.Length > 12)
                        {
                            downloadC.IsSepSave = parts[12].Equals("1");
                        }
                        if (parts.Length > 13)
                        {
                            itmxExplicit.IsChecked = parts[13].Equals("1");
                            showExplicit = !itmxExplicit.IsChecked;
                        }
                        if (parts.Length > 14)
                        {
                            namePatter = parts[14];
                        }
                        if (parts.Length > 15)
                        {
                            txtNum.Text = parts[15];
                        }
                        if (parts.Length > 16)
                        {
                            bgSt = (System.Windows.Media.Stretch)Enum.Parse(typeof(System.Windows.Media.Stretch), parts[16]);
                        }
                        if (parts.Length > 17)
                        {
                            bgHe = (System.Windows.Media.AlignmentX)Enum.Parse(typeof(System.Windows.Media.AlignmentX), parts[17]);
                        }
                        if (parts.Length > 18)
                        {
                            bgVe = (System.Windows.Media.AlignmentY)Enum.Parse(typeof(System.Windows.Media.AlignmentY), parts[18]);
                        }
                        if (parts.Length > 19)
                        {
                            bgOp = double.Parse(parts[19]);
                        }
                    }
                    //else itmJpg.IsChecked = lines[2].Trim().Equals("1");
                    else addressType = (AddressType)Enum.Parse(typeof(AddressType), lines[2].Trim());

                    for (int i = 3; i < lines.Length; i++)
                    {
                        if (lines[i].Trim().Length > 0)
                        {
                            if (lines[i].Contains(':'))
                            {
                                string[] parts = lines[i].Trim().Split(':');
                                viewedIds[parts[0]] = new ViewedID();
                                viewedIds[parts[0]].AddViewedRange(parts[1]);
                            }
                            else
                            {
                                //向前兼容
                                if (i - 3 >= SiteManager.Instance.Sites.Count) break;
                                viewedIds[SiteManager.Instance.Sites[i - 3].ShortName] = new ViewedID();
                                viewedIds[SiteManager.Instance.Sites[i - 3].ShortName].AddViewedRange(lines[i].Trim());
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "读取配置文件失败\r\n" + ex.Message, "Moe Loader", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }

            switch (addressType)
            {
                case AddressType.Ori:
                    itmTypeOri.IsChecked = true;
                    break;
                case AddressType.Jpg:
                    itmTypeJpg.IsChecked = true;
                    break;
                case AddressType.Pre:
                    itmTypePreview.IsChecked = true;
                    break;
                case AddressType.Small:
                    itmTypeSmall.IsChecked = true;
                    break;
            }

            //string logoPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\logo.png";
            //if (System.IO.File.Exists(logoPath))
            //{
                //image.Source = new BitmapImage(new Uri(logoPath, UriKind.Absolute));
            //}
            //else image.Source = new BitmapImage(new Uri("Images/logo1.png", UriKind.Relative));
        }