private bool requestThreadShutdown; //A variable which is used to allow clean stopping of the capture thread and determine if the escape key should close the application

        #endregion Fields

        #region Constructors

        public MainWindow()
        {
            InitializeComponent();

            //Register Important Window Events
            this.MouseDown+=new MouseButtonEventHandler(Window_MouseDown); //For dragging the form
            this.KeyDown += new KeyEventHandler(MainWindow_KeyDown); //For keyboard shortcuts
            this.SizeChanged += new SizeChangedEventHandler(MainWindow_SizeChanged); //For modifying the capture region size

            //Generate File Constants
            imageDirPath = "";
            String[] pathParts = System.Reflection.Assembly.GetExecutingAssembly().Location.Split(new char[] { '\\' });
            for (int i = 0; i < pathParts.Length - 1; i++) //Strip out the exe name
                imageDirPath += pathParts[i] + '\\';
            appDir = imageDirPath; //Store the app path
            imageDirPath += "Output\\"; //Store the output directory path

            //Create Output Dir
            Directory.CreateDirectory(imageDirPath);

            //Store the initial background brush
            backgroundBrush = this.Background.Clone();

            //Show instructions
            notificationPopupText.Text = "Resize, drag, record for up to 6 hours. Escape to stop recording or quit if you're not recording. F1 or button to record.\r\n<Click to Close...>";
            notificationPopup.IsOpen = true;

            //Sync Popup Location to Window
            this.LocationChanged += delegate(object sender, EventArgs args)
            {
                var offset = notificationPopup.HorizontalOffset;
                notificationPopup.HorizontalOffset = offset + 1;
                notificationPopup.HorizontalOffset = offset;
            };
        }
Пример #2
0
 // C'tor
 internal Player(Definitions.GameDef g, string name, byte id, ulong pkey)
 {
     // Init fields
     this.name = name; this.Id = id; this.PublicKey = pkey;
     // Register the player
     all.Add(this);
     OnPropertyChanged("Color");
     // Create the color brushes
     solidBrush = new System.Windows.Media.SolidColorBrush(Color);
     solidBrush.Freeze();
     transparentBrush = new System.Windows.Media.SolidColorBrush(Color);
     transparentBrush.Opacity = 0.4;
     transparentBrush.Freeze();
     OnPropertyChanged("Brush");
     OnPropertyChanged("TransparentBrush");
     // Create counters
     counters = new Counter[g.PlayerDefinition.Counters != null ? g.PlayerDefinition.Counters.Length : 0];
     for (int i = 0; i < Counters.Length; i++)
         Counters[i] = new Counter(this, g.PlayerDefinition.Counters[i]);
       // Create variables
       Variables = new Dictionary<string, int>();
       foreach (var varDef in g.Variables.Where(v => !v.Global))
     Variables.Add(varDef.Name, varDef.DefaultValue);
     // Create a hand, if any
     if (g.PlayerDefinition.Hand != null)
         hand = new Hand(this, g.PlayerDefinition.Hand);
     // Create groups
     groups = new Group[g.PlayerDefinition.Groups != null ? g.PlayerDefinition.Groups.Length + 1 : 1];
     groups[0] = hand;
     for (int i = 1; i < IndexedGroups.Length; i++)
         groups[i] = new Pile(this, g.PlayerDefinition.Groups[i - 1]);
     // Raise the event
     if (PlayerAdded != null) PlayerAdded(null, new PlayerEventArgs(this));
 }
Пример #3
0
 protected static void SetupBrushes()
 {
     if (_highlightdBrush == null)
     {
         object o = System.Windows.Application.Current.FindResource("AccentColorBrush");
         if (o == null)
             _highlightdBrush = System.Windows.Media.Brushes.Transparent;
         else
             _highlightdBrush = (System.Windows.Media.Brush)o;
     }
     if (_normalBrush == null)
     {
         object o = System.Windows.Application.Current.FindResource("ControlBackgroundBrush");
         if (o == null)
             _normalBrush = System.Windows.Media.Brushes.Transparent;
         else
             _normalBrush = (System.Windows.Media.Brush)o;
     }
     if (_disabledBrush == null)
     {
         object o = System.Windows.Application.Current.FindResource("GrayBrush4");
         if (o == null)
             _disabledBrush = System.Windows.Media.Brushes.Transparent;
         else
             _disabledBrush = (System.Windows.Media.Brush)o;
     }
     if (_disconnectedBrush == null)
     {
         object o = System.Windows.Application.Current.FindResource("GrayBrush8");
         if (o == null)
             _disconnectedBrush = System.Windows.Media.Brushes.Transparent;
         else
             _disconnectedBrush = (System.Windows.Media.Brush)o;
     }
 }
Пример #4
0
 static Buttons()
 {
     ResourceDictionary rd = GetDictionary("GameButton");
       GameButton = rd["GameButton"] as ControlTemplate;
       Luster = rd["Luster"] as Brush;
       GrayBg = rd["GrayBG"] as Brush;
       Colorful = GetStyle("Colorful");
       Text = GetStyle("Text");
       Pokemon = GetStyle("Pokemon");
       rd = GetDictionary("Move");
       Move = rd["MoveButton"] as Style;
       Struggle = rd["StruggleButton"] as Style;
 }
Пример #5
0
        /// <summary>
        /// Apply Blur Effect on the window
        /// </summary>
        /// <param name="win">parent window</param>
        public static void ApplyEffect(this System.Windows.Window win)
        {
            // Create new effective objects
            var objBlur = new System.Windows.Media.Effects.BlurEffect { Radius = 5 };
            var mask = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.DarkGray) { Opacity = 50 };

            // Buffering ...
            effectBuffer = win.Effect;
            brushBuffer = win.OpacityMask;

            // Change this.win effective objects
            win.Dispatcher.Invoke(new Action(delegate { win.Effect = objBlur; }), System.Windows.Threading.DispatcherPriority.Normal);
            win.Dispatcher.Invoke(new Action(delegate { win.OpacityMask = mask; }), System.Windows.Threading.DispatcherPriority.Normal);
        }
Пример #6
0
        protected override void OnPreviewKeyDown( KeyEventArgs e )
        {
            this.mainWindowViewModel.OnPreviewKeyDown( e );

            // konami code management.
            if ( _originalBackground == null )
            {
                _originalBackground = MainPanel.Background;
                _originalViewBox = DepthViewerPanel.Children[0];
            }
            string i = "UpUpDownDownLeftRightLeftRightBA";
            if ( e.Key.ToString() == "Up" && _konami != "Up" )
            {
                _konami = "";
            }
            _konami = ( _konami + e.Key.ToString() );
            // Debug.Print(konami)
            if ( ( _konami == i ) )
            {
                mainWindowViewModel.Konami = true;
                string fileName = "..\\..\\Resources\\mad_duck.jpg";
                System.Windows.Media.Imaging.BitmapImage image = new System.Windows.Media.Imaging.BitmapImage( new System.Uri( fileName, System.UriKind.Relative ) );
                System.Windows.Media.ImageBrush brush = new System.Windows.Media.ImageBrush();
                brush.ImageSource = image;
                MainPanel.Background = brush;

                Viewbox v = new Viewbox();
                MediaElement me = new MediaElement();
                fileName = "..\\..\\Resources\\Star Wars Ducks.mp4";
                me.Source = new System.Uri( fileName, System.UriKind.Relative );
                me.LoadedBehavior = MediaState.Manual;
                me.MediaEnded += new RoutedEventHandler( delegate( object s, RoutedEventArgs re ) { me.Stop(); me.Play(); } );
                me.Play();
                v.Child = me;
                DepthViewerPanel.Children.RemoveAt( 0 );
                DepthViewerPanel.Children.Add( v );
            }
            else if ( _konami.Length > i.Length )
            {
                mainWindowViewModel.Konami = false;
                MainPanel.Background = _originalBackground;
                DepthViewerPanel.Children.RemoveAt( 0 );
                DepthViewerPanel.Children.Add( _originalViewBox );
            }
        }
Пример #7
0
 public static TextBlock Append(this TextBlock block, string text, WpfBrush brush)
 {
     return(block.Append(text, false, false, brush));
 }
Пример #8
0
        public void EnableWindowElements(bool directoryIsSet)
        {
            Action<UIElement> enable = (setting) => setting.IsEnabled = directoryIsSet;

            enable(cBoxTitle);
            enable(cBoxAlbumArtist);
            enable(cBoxContArtists);
            enable(cBoxAlbum);
            enable(cBoxYear);
            enable(cBoxTrackNo);
            enable(cBoxGenres);
            enable(cBoxSelectAll);

            enable(comboBoxTitle);
            enable(comboBoxAlbumArtist);
            enable(comboBoxContArtists);
            enable(comboBoxAlbum);
            enable(comboBoxYear);
            enable(comboBoxTrackNo);
            enable(comboBoxGenre);

            enable(btnReset);
            enable(btnClear);
            enable(btnRefresh);
            enable(btnSave);

            enable(btnSearchReplace);
            enable(btnCheckFormMsg);

            enable(comboBoxFormat);

            enable(cBoxApplyToAll);
            enable(cBoxAutoNext);

            enable(btnSuggest);
            enable(btnAddToDB);

            if (directoryIsSet)
            {
                listViewBackground = listViewAudioFiles.Background;
                listViewAudioFiles.Background = null;
            }
        }
 void SetCurrentStatusMessage(string message, Brush foreground/*, Dispatcher dispatcher*/)
 {
     CurrentStatusTextBlock.Foreground = foreground;
     CurrentStatusTextBlock.Text = message;
 }
        public TestExecWindowControl()
            : base()
        {
            this.InitializeComponent();

            m_executionTimer.Enabled = false;
            m_executionTimer.Tick   += new EventHandler(OnExecutionTimeout);
            for (int i = 0; i < 4; ++i)
            {
                m_state[i] = State.IDLE;
            }
            m_originalBrushWindow = mainGrid.Background;
            {
                List <string> data = new List <string>();
                data.Add("sort as read");
                data.Add("reverse read order");
                data.Add("sort A->Z");
                data.Add("sort Z->A");

                cbxSortOrder.ItemsSource   = data;
                cbxSortOrder.SelectedIndex = (int)m_sortOrder;
            }
            {
                List <string> data = new List <string>();
                data.Add("show log");
                data.Add("hide log");

                cbxLogVisibility.ItemsSource   = data;
                cbxLogVisibility.SelectedIndex = m_logVisible ? 0 : 1;
            }
            {
                List <string> data = new List <string>();
                data.Add("regular output");
                data.Add("verbous output");
                data.Add("detailed output");

                int outputLevel = Properties.Settings.Default.IdxOutputLevel + 1;
                cbxOutputLevel.ItemsSource   = data;
                cbxOutputLevel.SelectedIndex = outputLevel - 1;
            }
            {
                List <string> data = new List <string>();
                data.Add("leak check");
                data.Add("no leak check");

                cbxMemLeakCheck.ItemsSource = data;
                bool leakCheck = Properties.Settings.Default.CheckForMemoryLeaks;
                cbxMemLeakCheck.SelectedIndex = leakCheck ? 0 : 1;
            }
            {
                List <string> data = new List <string>();
                data.Add("wait for test app without time limit");
                data.Add("wait for test app max 30 sec");
                data.Add("wait for test app max 1 min");
                data.Add("wait for test app max 2 min");
                data.Add("wait for test app max 5 min");
                data.Add("wait for test app max 10 min");
                data.Add("wait for test app max 20 min");
                data.Add("wait for test app max 30 min");
                data.Add("wait for test app max 40 min");
                data.Add("wait for test app max 60 min");

                cbxMaxExecutionTime.ItemsSource   = data;
                cbxMaxExecutionTime.SelectedIndex = (int)m_waitMode;
            }

            {
                List <string> data = new List <string>();
                data.Add("");
                data.Add("BOOST options:");
                data.Add("--detect_memory_leak=0");
                data.Add("--log_level=test_suite");
                data.Add("");
                data.Add("TTB Runner options:");
                data.Add("-- -checkForMemLeaks OFF");
                data.Add("-- -help");
                data.Add("");
                data.Add("custom options:");
                data.Add("-- -prefixEvents TTB_EXP");

                cbxDefaultArgs.ItemsSource   = data;
                cbxDefaultArgs.SelectedIndex = 0;
                cbxDefaultArgs.IsEditable    = true;
                cbxDefaultArgs.Text          = Properties.Settings.Default.GeneralCmdLineArgs;
            }
            {
                m_dataDescTestApps = new List <string>();
                m_dataDescTestApps.Add(Properties.Settings.Default.DescTestApps1);
                m_dataDescTestApps.Add(Properties.Settings.Default.DescTestApps2);
                m_dataDescTestApps.Add(Properties.Settings.Default.DescTestApps3);
                m_dataDescTestApps.Add(Properties.Settings.Default.DescTestApps4);
                m_dataDescTestApps.Add(Properties.Settings.Default.DescTestApps5);
                m_dataDescTestApps.Add(Properties.Settings.Default.DescTestApps6);
                m_dataDescTestApps.Add(Properties.Settings.Default.DescTestApps7);
                m_dataDescTestApps.Add(Properties.Settings.Default.DescTestApps8);
            }
        }
Пример #11
0
        /// <summary>
        /// Plays the game and exports the results onto a graph
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPlay_Click(object sender, EventArgs e)
        {
            // Reset the score
            csv        = new StringBuilder();
            totalScore = 0;

            // Clear the chart
            scoreChart.Series = new SeriesCollection();

            // Create a grid for benchmarking (100px by 100px, 1 by 2 grid)
            Grid benchmarkGrid = new Grid(100, 100, 1, 2, this.matrix, WrapMode.Default);

            // For every available strategy
            foreach (Strategy strat in cbStrategy1.Items)
            {
                // Set the strategy (reset the strategy)
                Strategy strategyP1 = (Strategy)cbStrategy1.Items[cbStrategy1.SelectedIndex];
                benchmarkGrid.setStrategy(0, 0, strategyP1);

                // Set the opposing player's strategy
                benchmarkGrid.setStrategy(1, 0, strat);

                // Get the color from the strategy
                System.Windows.Media.BrushConverter converter = new System.Windows.Media.BrushConverter();
                System.Windows.Media.Brush          brush     = (System.Windows.Media.Brush)converter.ConvertFromString(strat.getColor().ToHex());


                // Play the rounds
                for (int i = 0; i < tbNbTurns.Value; i++)
                {
                    benchmarkGrid.step();
                    score      += benchmarkGrid.Cells[0, 0].Score;
                    totalScore += benchmarkGrid.Cells[0, 0].Score;
                    csv.AppendLine(totalScore.ToString());
                }

                // Check if we should export as csv or not
                if (SHOULD_EXPORT_DATA)
                {
                    // Make sure the csv directory exists
                    if (!Directory.Exists("csv/"))
                    {
                        Directory.CreateDirectory("csv");
                    }

                    // Write the data
                    File.WriteAllText("csv/" + strategyP1.ToString() + " benchmark.csv", csv.ToString());
                }

                // Add the score to the chart
                scoreChart.Series.Add(new ColumnSeries
                {
                    Title  = strat.ToString(),
                    Values = new ChartValues <double> {
                        score
                    },
                    Fill = brush,
                });

                // Reset the score
                score = 0;
            }

            // Set the total score label
            lblTotalScore.Text = "Total score: " + totalScore;

            this.Size = new Size(820, 340);
        }
Пример #12
0
        public System.Windows.Media.Brush GetMediaBrush()
        {
            if (_mediaBrush == null)
            {
                if (type == BrushType.Solid)
                {
                    System.Windows.Media.SolidColorBrush brush = new System.Windows.Media.SolidColorBrush(
                        Utils.ColorUtils.DrawingColorToMediaColor(colorGradients[0.0f])
                        );
                    brush.Freeze();

                    _mediaBrush = brush;
                }
                else if (type == BrushType.Linear)
                {
                    System.Windows.Media.GradientStopCollection collection = new System.Windows.Media.GradientStopCollection();

                    foreach (var kvp in colorGradients)
                    {
                        collection.Add(
                            new System.Windows.Media.GradientStop(
                                Utils.ColorUtils.DrawingColorToMediaColor(kvp.Value),
                                kvp.Key)
                            );
                    }

                    System.Windows.Media.LinearGradientBrush brush = new System.Windows.Media.LinearGradientBrush(collection);
                    brush.StartPoint = new System.Windows.Point(start.X, start.Y);
                    brush.EndPoint   = new System.Windows.Point(end.X, end.Y);

                    switch (wrap)
                    {
                    case BrushWrap.None:
                        brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Pad;
                        break;

                    case BrushWrap.Repeat:
                        brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Repeat;
                        break;

                    case BrushWrap.Reflect:
                        brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Reflect;
                        break;
                    }

                    _mediaBrush = brush;
                }
                else if (type == BrushType.Radial)
                {
                    System.Windows.Media.GradientStopCollection collection = new System.Windows.Media.GradientStopCollection();

                    foreach (var kvp in colorGradients)
                    {
                        collection.Add(
                            new System.Windows.Media.GradientStop(
                                Utils.ColorUtils.DrawingColorToMediaColor(kvp.Value),
                                kvp.Key)
                            );
                    }

                    System.Windows.Media.RadialGradientBrush brush = new System.Windows.Media.RadialGradientBrush(collection);
                    brush.Center  = new System.Windows.Point(center.X, center.Y);
                    brush.RadiusX = end.X / 2.0;
                    brush.RadiusY = end.Y / 2.0;

                    switch (wrap)
                    {
                    case BrushWrap.None:
                        brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Pad;
                        break;

                    case BrushWrap.Repeat:
                        brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Repeat;
                        break;

                    case BrushWrap.Reflect:
                        brush.SpreadMethod = System.Windows.Media.GradientSpreadMethod.Reflect;
                        break;
                    }

                    _mediaBrush = brush;
                }
                else
                {
                    System.Windows.Media.SolidColorBrush brush = new System.Windows.Media.SolidColorBrush(
                        System.Windows.Media.Color.FromArgb(255, 255, 0, 0)
                        );
                    brush.Freeze();

                    _mediaBrush = brush;
                }
            }

            return(_mediaBrush);
        }
Пример #13
0
        /// <summary>
        /// Set up the form after it is loaded
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainView_Load(object sender, EventArgs e)
        {
            // Make a list of all our available strategies
            availableStrategies = new List <Strategy>();

            // To add more strategies, add them to the list
            availableStrategies.Add(new StratRandom());
            availableStrategies.Add(new StratTitForTat());
            availableStrategies.Add(new StratBlinker());
            availableStrategies.Add(new StratAlwaysCooperate());
            availableStrategies.Add(new StratAlwaysDefect());
            availableStrategies.Add(new StratTitForTwoTats());
            availableStrategies.Add(new StratGrimTrigger());
            availableStrategies.Add(new StratFortress());
            availableStrategies.Add(new StratAdaptativePavlov());
            availableStrategies.Add(new StratSuspiciousTitForTat());

            // Sort the list
            availableStrategies.Sort();

            // Initialize the payoff matrix with default values
            payoffMatrix = new PayoffMatrix();

            // Initialize our grid of cells
            mainGrid = new Grid(pbGrid.Width, pbGrid.Height, tbLines.Value, tbColumns.Value, payoffMatrix, gridWrappingMode);

            // Initialise the combobox with strategies and colors
            cbStrategies.AddStrategies(availableStrategies);

            // Select the first element by default
            cbStrategies.SelectedIndex = 0;

            // Set the user help text
            lblUserHelp.Text = "Click on a cell to change its strategy."
                               + Environment.NewLine + "The default strategy is "
                               + Cell.DEFAULT_STRATEGY.ToString();

            // Update the other labels
            updateLabels();

            // CHARTS
            // Pie chart
            pieStrategy.InnerRadius       = 50;
            pieStrategy.LegendLocation    = LegendLocation.Right;
            pieStrategy.DisableAnimations = true;
            pieStrategy.Series            = new SeriesCollection();

            foreach (Strategy strategy in availableStrategies)
            {
                // Get the color from the strategy
                System.Windows.Media.BrushConverter converter = new System.Windows.Media.BrushConverter();
                System.Windows.Media.Brush          brush     = (System.Windows.Media.Brush)converter.ConvertFromString(strategy.getColor().ToHex());

                // Create an object for storing values on the pie chart
                PieSeries stratToAdd = new PieSeries
                {
                    Title  = strategy.ToString(),
                    Values = new ChartValues <double>
                    {
                        mainGrid.findCountOfStrategy(strategy)
                    },
                    DataLabels = true,
                    Fill       = brush
                };

                stratToAdd.Visibility = System.Windows.Visibility.Hidden;


                // Add the values to the pie chart
                pieStrategy.Series.Add(stratToAdd);
            }

            // Cartesian
            cartesianStrategy.LegendLocation = LegendLocation.Right;
            cartesianStrategy.AxisX.Add(new Axis
            {
                Title          = "Current Generation",
                LabelFormatter = value => value.ToString()
            });

            cartesianStrategy.AxisY.Add(new Axis
            {
                Title          = "Number of Days in Prison",
                LabelFormatter = value => value.ToString(),
            });

            // Initialize the cartesian chart
            initializeChart();
            updateDonutChart();
        }
Пример #14
0
 public static WpfText ToFormattedText(string text, double size, WpfBrush brush)
 {
     return(new WpfText(text, System.Globalization.CultureInfo.CurrentCulture, FlowDirection.LeftToRight, StatusText, size, brush));
 }
Пример #15
0
 public static Run Render(this string text, WpfBrush brush)
 {
     return(text.Render(false, false, brush));
 }
Пример #16
0
 public static Run Render(this ISymbol symbol, string alias, WpfBrush brush)
 {
     return(symbol.Render(alias, brush == null, brush));
 }
Пример #17
0
 public static TextBlock AddSymbol(this TextBlock block, ISymbol symbol, bool bold, WpfBrush brush)
 {
     if (symbol != null)
     {
         block.Inlines.Add(symbol.Render(null, bold, brush));
     }
     return(block);
 }
Пример #18
0
 public static TextBlock AddSymbol(this TextBlock block, ISymbol symbol, string alias, WpfBrush brush)
 {
     if (symbol != null)
     {
         block.Inlines.Add(symbol.Render(alias, false, brush));
     }
     return(block);
 }
Пример #19
0
 public static TextBlock Append(this TextBlock block, string text, bool bold, bool italic, WpfBrush brush)
 {
     block.Inlines.Add(Render(text, bold, italic, brush));
     return(block);
 }
Пример #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Brush" /> class.
 /// </summary>
 /// <param name="uiBrush">UI object used to represent brush.</param>
 /// <param name="opacity">Brush opacity.</param>
 public Brush(System.Windows.Media.Brush uiBrush, double opacity)
 {
     Opacity         = opacity;
     UIBrush         = uiBrush;
     uiBrush.Opacity = opacity;
 }
Пример #21
0
        public MainWindow()
        {
            // Set window state
            WindowState = _settings.WindowState;

            // Create Json file to store bookmarks
            if (!File.Exists("bookmarks.json"))
            {
                File.Create("bookmarks.json");
            }

            InitializeComponent();
            DataContext = this;

            // Get app accent and theme from settings and set it
            ThemeManager.ChangeAppStyle(Application.Current,
                                        ThemeManager.GetAccent(_settings.Accent),
                                        ThemeManager.GetAppTheme(_settings.Theme));

            // Set accent combobox data source
            Accent_ComboBox.ItemsSource = Enum.GetValues(typeof(LooksManager.Accents)).Cast <LooksManager.Accents>();

            // Set accent combobox item based on settings
            Accent_ComboBox.SelectedIndex = (int)Enum.Parse(typeof(LooksManager.Accents), _settings.Accent);

            // Set theme button icon based on settings
            if (_settings.Theme == "BaseLight")
            {
                DarkMode_Icon.Kind  = MahApps.Metro.IconPacks.PackIconFontAwesomeKind.SunRegular;
                _darkmodeIconToggle = false;
            }
            else
            {
                DarkMode_Icon.Kind  = MahApps.Metro.IconPacks.PackIconFontAwesomeKind.MoonRegular;
                _darkmodeIconToggle = true;
            }

            // Set download path
            if (_settings.DownloadLocation == "")
            {
                _settings.DownloadLocation = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\DerpiViewer\";
            }

            var dlPath = _settings.DownloadLocation;

            // Create the directory if doesn't exist
            Directory.CreateDirectory(dlPath);

            // Set path text
            DlPathBox.Text = _settings.DownloadLocation;

            // Set token
            TokenBox.Text = _settings.Token;

            // Set ratings
            Safe_Switch.IsChecked         = _settings.Safe;
            Questionable_Switch.IsChecked = _settings.Questionable;
            Explicit_Switch.IsChecked     = _settings.Explicit;

            // Set border brush
            BorderBrush = QueryNameTextbox.BorderBrush;
        }
Пример #22
0
 void SetCurrentStatusMessage(string message, Brush foreground /*, Dispatcher dispatcher*/)
 {
     CurrentStatusTextBlock.Foreground = foreground;
     CurrentStatusTextBlock.Text       = message;
 }
Пример #23
0
        public EffectBrush(System.Windows.Media.Brush brush)
        {
            if (brush is System.Windows.Media.SolidColorBrush)
            {
                type = BrushType.Solid;

                wrap = BrushWrap.Repeat;

                colorGradients.Add(0.0f, Utils.ColorUtils.MediaColorToDrawingColor((brush as System.Windows.Media.SolidColorBrush).Color));
                colorGradients.Add(1.0f, Utils.ColorUtils.MediaColorToDrawingColor((brush as System.Windows.Media.SolidColorBrush).Color));
            }
            else if (brush is System.Windows.Media.LinearGradientBrush)
            {
                type = BrushType.Linear;

                System.Windows.Media.LinearGradientBrush lgb = (brush as System.Windows.Media.LinearGradientBrush);

                start  = new System.Drawing.PointF((float)lgb.StartPoint.X, (float)lgb.StartPoint.Y);
                end    = new System.Drawing.PointF((float)lgb.EndPoint.X, (float)lgb.EndPoint.Y);
                center = new System.Drawing.PointF(0.0f, 0.0f);

                switch (lgb.SpreadMethod)
                {
                case (System.Windows.Media.GradientSpreadMethod.Pad):
                    wrap = BrushWrap.None;
                    break;

                case (System.Windows.Media.GradientSpreadMethod.Repeat):
                    wrap = BrushWrap.Repeat;
                    break;

                case (System.Windows.Media.GradientSpreadMethod.Reflect):
                    wrap = BrushWrap.Reflect;
                    break;
                }

                foreach (var grad in lgb.GradientStops)
                {
                    if (!colorGradients.ContainsKey((float)grad.Offset) && ((float)grad.Offset >= 0.0f && (float)grad.Offset <= 1.0f))
                    {
                        colorGradients.Add(
                            (float)grad.Offset,
                            Utils.ColorUtils.MediaColorToDrawingColor(grad.Color)
                            );
                    }
                }
            }
            else if (brush is System.Windows.Media.RadialGradientBrush)
            {
                type = BrushType.Radial;

                System.Windows.Media.RadialGradientBrush rgb = (brush as System.Windows.Media.RadialGradientBrush);

                start  = new System.Drawing.PointF(0, 0);
                end    = new System.Drawing.PointF((float)rgb.RadiusX * 2.0f, (float)rgb.RadiusY * 2.0f);
                center = new System.Drawing.PointF(
                    (float)rgb.Center.X,
                    (float)rgb.Center.Y
                    );

                switch (rgb.SpreadMethod)
                {
                case (System.Windows.Media.GradientSpreadMethod.Pad):
                    wrap = BrushWrap.None;
                    break;

                case (System.Windows.Media.GradientSpreadMethod.Repeat):
                    wrap = BrushWrap.Repeat;
                    break;

                case (System.Windows.Media.GradientSpreadMethod.Reflect):
                    wrap = BrushWrap.Reflect;
                    break;
                }

                foreach (var grad in rgb.GradientStops)
                {
                    if (!colorGradients.ContainsKey((float)grad.Offset) && ((float)grad.Offset >= 0.0f && (float)grad.Offset <= 1.0f))
                    {
                        colorGradients.Add(
                            (float)grad.Offset,
                            Utils.ColorUtils.MediaColorToDrawingColor(grad.Color)
                            );
                    }
                }
            }
            else
            {
            }

            if (colorGradients.Count > 0)
            {
                bool firstFound = false;
                System.Drawing.Color first_color = new System.Drawing.Color();
                System.Drawing.Color last_color  = new System.Drawing.Color();

                foreach (var kvp in colorGradients)
                {
                    if (!firstFound)
                    {
                        first_color = kvp.Value;
                        firstFound  = true;
                    }

                    last_color = kvp.Value;
                }

                if (!colorGradients.ContainsKey(0.0f))
                {
                    colorGradients.Add(0.0f, first_color);
                }

                if (!colorGradients.ContainsKey(1.0f))
                {
                    colorGradients.Add(1.0f, last_color);
                }
            }
            else
            {
                if (!colorGradients.ContainsKey(0.0f))
                {
                    colorGradients.Add(0.0f, System.Drawing.Color.Transparent);
                }

                if (!colorGradients.ContainsKey(1.0f))
                {
                    colorGradients.Add(1.0f, System.Drawing.Color.Transparent);
                }
            }
        }
Пример #24
0
        private void updateAllPins()
        {
            if (this.customPins != null)
            {
                int nOdx   = 0;
                int nCount = 0;

                nCount = this.customPins.Count;
                for (nOdx = 0; nOdx < nCount; nOdx++)
                {
                    string sPinLabel = this.customPins[nOdx].Latitude.ToString("F2").Substring(0, 2);
                    MapControl.Location        aLoc     = new MapControl.Location(this.customPins[nOdx].Latitude, this.customPins[nOdx].Longitude);
                    System.Windows.Media.Brush pinBrush = System.Windows.Media.Brushes.Blue;
                    if (this.customPins[nOdx].BluePin)
                    {
                        pinBrush = System.Windows.Media.Brushes.Blue;
                    }
                    else
                    {
                        /** Orange Push Pin */
                        pinBrush = System.Windows.Media.Brushes.Orange;
                    }

                    ObservableCollection <Point> somePushpins = new ObservableCollection <Point>();

                    /**
                     * From Xaml Map Control github code (codeplex)
                     *  Pushpins = new ObservableCollection<Point>();
                     *  Pushpins.Add(
                     *      new Point
                     *      {
                     *          Name = "WHV - Eckwarderhörne",
                     *          Location = new Location(53.5495, 8.1877)
                     *      });
                     **/

                    Point aPushPin = new Point {
                        Name     = sPinLabel,
                        Location = new MapControl.Location(aLoc.Latitude, aLoc.Longitude)
                    };

                    System.Windows.Style style = new System.Windows.Style {
                        TargetType = typeof(MapItem)
                    };
                    style.Setters.Add(new System.Windows.Setter(MapPanel.LocationProperty, aLoc));
                    style.Setters.Add(new System.Windows.Setter(MapItem.VerticalContentAlignmentProperty, System.Windows.VerticalAlignment.Bottom));
                    style.Setters.Add(new System.Windows.Setter(MapItem.ForegroundProperty, System.Windows.Media.Brushes.Black));
                    style.Setters.Add(new System.Windows.Setter(MapItem.BackgroundProperty, pinBrush));
                    style.Setters.Add(new System.Windows.Setter(MapItem.VisibilityProperty, System.Windows.Visibility.Visible));
                    System.Windows.FrameworkElementFactory aPin = new FrameworkElementFactory(typeof(MapControl.Pushpin));
                    aPin.SetValue(MapControl.Pushpin.ContentProperty, sPinLabel);
                    aPin.SetValue(MapControl.Pushpin.ForegroundProperty, System.Windows.Media.Brushes.Black);
                    aPin.SetValue(MapControl.Pushpin.BackgroundProperty, pinBrush);
                    System.Windows.Controls.ControlTemplate ct = new System.Windows.Controls.ControlTemplate(typeof(MapControl.MapItem));
                    ct.VisualTree = aPin;
                    style.Setters.Add(new System.Windows.Setter(MapItem.TemplateProperty, ct));

                    somePushpins.Add(aPushPin);

                    MapControl.MapItemsControl aControl = new MapItemsControl {
                        ItemsSource                   = somePushpins,
                        ItemContainerStyle            = style,
                        IsSynchronizedWithCurrentItem = true
                    };

                    Control.Children.Add(aControl);
                }
            }
        }
Пример #25
0
 public static void SetLineNumbersForeground(TextBox target, System.Windows.Media.Brush value)
 {
     target.SetValue(LineNumbersForegroundProperty, value);
 }
Пример #26
0
        private string CssColorFromBrush(System.Windows.Media.Brush brush)
        {
            var sb = brush as System.Windows.Media.SolidColorBrush;

            return(Invariant($"rgb({sb.Color.R}, {sb.Color.G}, {sb.Color.B})"));
        }
Пример #27
0
 protected virtual new void OnDraw(System.Windows.Media.DrawingContext drawingContext, System.Windows.Input.StylusPointCollection stylusPoints, System.Windows.Media.Geometry geometry, System.Windows.Media.Brush fillBrush)
 {
 }
Пример #28
0
        public void ShowLocalModal(FrameworkElement content, object title, bool isResizable = true, bool isSpan = false, bool isNotCloseOnEscapeButton = false, bool allowCloseWindow = true)
        {
            var children = content as ILocalChildren;

            System.Windows.Media.Brush modalBackground = null;
            _isNotCloseOnEscapeButton = isNotCloseOnEscapeButton;
            var isTrueModal = false;
            var id          = Guid.Empty;

            if (children != null)
            {
                if (children.Id == Guid.Empty)
                {
                    children.Id = Guid.NewGuid();
                }
                id = children.Id;

                if (children.LocalModalType != EnumLocalModalType.None)
                {
                    //Проверка открыто ли окно с таким содержимым
                    if (children.LocalModalType == EnumLocalModalType.UniqueById)
                    {
                        XamDialogWindow dw;
                        if (DialogWindowsCollection.TryGetValue(id, out dw) && dw != null && dw.WindowState != WindowState.Hidden)
                        {
                            return;
                        }
                        //Изменен тип коллекции, но логика сохранена
                        //if (dw.WindowState == WindowState.Hidden) return false;
                        //if (ch == null) return false;
                        //return ch.LocalModalType == EnumLocalModalType.UniqueById && ch.Id == children.Id;
                    }

                    if (children.LocalModalType == EnumLocalModalType.TrueModal)
                    {
                        modalBackground = System.Windows.Media.Brushes.LightSteelBlue;
                        isTrueModal     = true;
                    }
                }
            }

            if (id == Guid.Empty)
            {
                id = Guid.NewGuid();
            }

            var xamDialogWindow = new XamDialogWindow
            {
                StartupPosition       = StartupPosition.Center,
                ModalBackground       = modalBackground,
                Header                = title,
                IsModal               = true,
                IsResizable           = isResizable,
                Content               = content,
                Tag                   = id,
                CloseButtonVisibility = allowCloseWindow? Visibility.Visible: Visibility.Collapsed
            };

            if (isSpan)
            {
                if (RowDefinitions.Count > 0)
                {
                    SetRowSpan(xamDialogWindow, RowDefinitions.Count);
                }
                if (ColumnDefinitions.Count > 0)
                {
                    SetColumnSpan(xamDialogWindow, ColumnDefinitions.Count);
                }
            }

            Children.Add(xamDialogWindow);

            xamDialogWindow.WindowStateChanged += s_WindowStateChanged;
            if (isTrueModal)
            {
                xamDialogWindow.IsActiveChanged += xamDialogWindow_IsActiveChanged;
            }

            xamDialogWindow.Loaded   += XamDialogWindow_Loaded;
            xamDialogWindow.Unloaded += XamDialogWindow_Unloaded;

            xamDialogWindow.Show();

            if (!DialogWindowsCollection.IsEmpty)
            {
                var prevWindow = DialogWindowsCollection.Values.Last();
                if (prevWindow != null && prevWindow.WindowState != WindowState.Hidden)
                {
                    xamDialogWindow.Margin = new Thickness(prevWindow.Margin.Left + 6, prevWindow.Margin.Top + 12, 0, 0);
                }
            }

            if (isResizable)
            {
                xamDialogWindow.SizeChanged += OnDwSizeChanged;
            }
            else if (DialogWindowsCollection.IsEmpty)
            {
                SizeChanged += OnParentSizeChanged;
            }

            DialogWindowsCollection.TryAdd(id, xamDialogWindow);

            xamDialogWindow.Dispatcher.BeginInvoke((Action)(() => { xamDialogWindow.CenterDialogWindow(); }),
                                                   DispatcherPriority.Background);
        }
Пример #29
0
 private void _command_Executed(object sender, object parameter)
 {
     TitleColor = System.Windows.Media.Brushes.Gray;
     NotifyPropertyChanged("TitleColor");
 }
Пример #30
0
 public static void CleanupBrushes()
 {
     _disabledBrush = null;
     _disconnectedBrush = null;
     _normalBrush = null;
     _highlightdBrush = null;
 }
        private void BindSelectedStop(bool bRefreshUpdatableAttributes)
        {
            if (_defaultButtonBackgroud == null)
            _defaultButtonBackgroud = AtStopButton.Background;

              if (StopsListBox.SelectedItems.Count == 0)
            return;

              //Stop stop = e.AddedItems[0] as Stop;
              Stop stop = StopsListBox.SelectedItems[0] as Stop;
              if (stop == null)
            return;

              // Stop ID
              string stopId = stop.GetPropertyValueAsString(Stop.IdFieldAlias);
              if (stopId == null)
              {
            Log.Trace("Stop Details - missing stop ID field alias - '" + Stop.IdFieldAlias + "'");
            stopId = "";
              }
              StopNameText.Text = stopId;

              // Stop Address
              string address = stop.GetPropertyValueAsString(Stop.AddressFieldAlias);
              if (address == null)
              {
            Log.Trace("Stop Details - missing address field alias - '" + Stop.AddressFieldAlias + "'");
            address = "";
              }
              StopAddressText.Text = address;

              // Stop Sequence
              string sequence = stop.GetPropertyValueAsString(Stop.SequenceFieldAlias);
              if (sequence == null)
              {
            Log.Trace("Stop Details - missing sequence field alias - '" + Stop.SequenceFieldAlias + "'");
            sequence = "";
              }
              StopSequenceText.Text = "#" + sequence;

              // Stop Type
              string type = stop.Type;
              if (type == null)
            type = "Stop";

              StopTypeText.Text = type;

              // Stop Image
              StopImage.Source = stop.ImageSource;

              // Stop ETA
              StopEtaText.Text = stop.ETA;

              // Stop ETD
              StopEtdText.Text = stop.ETD;

              // Stop Status
              string status = stop.Status;
              if (status == null)
            status = "";

              // AtStop Button
              string key = type + "," + Stop.StopStatusAtStop;
              string[] buttonRemarks = GetStatusRemarks(key);
              if (buttonRemarks == null || buttonRemarks.Length == 0)
            AtStopButton.Visibility = Visibility.Collapsed;
              else
            AtStopButton.Visibility = Visibility.Visible;

              if (status.Equals(Stop.StopStatusAtStop))
            AtStopButton.Background = _highlightedButtonBackgroud;
              else
            AtStopButton.Background = _defaultButtonBackgroud;

              // Completed Button
              key = type + "," + Stop.StopStatusCompleted;
              buttonRemarks = GetStatusRemarks(key);
              if (buttonRemarks == null || buttonRemarks.Length == 0)
            CompletedButton.Visibility = Visibility.Collapsed;
              else
            CompletedButton.Visibility = Visibility.Visible;

              if (status.Equals(Stop.StopStatusCompleted))
            CompletedButton.Background = _highlightedButtonBackgroud;
              else
            CompletedButton.Background = _defaultButtonBackgroud;

              // Exception Button
              key = type + "," + Stop.StopStatusException;
              buttonRemarks = GetStatusRemarks(key);
              if (buttonRemarks == null || buttonRemarks.Length == 0)
            ExceptionButton.Visibility = Visibility.Collapsed;
              else
            ExceptionButton.Visibility = Visibility.Visible;

              if (status.Equals(Stop.StopStatusException))
            ExceptionButton.Background = _highlightedButtonBackgroud;
              else
            ExceptionButton.Background = _defaultButtonBackgroud;

              // Attributes
              stopAttributesDataGrid.ItemsSource = stop.GetAttributes();

              // Updatable Attributes
              if (bRefreshUpdatableAttributes)
            stopUpdatableAttributesDataGrid.ItemsSource = stop.UpdatableAttributes;

              // Show or hide the Updates Stack Panel
              if (stopUpdatableAttributesDataGrid.ItemsSource == null || ((ObservableCollection<ItemAttribute>)stopUpdatableAttributesDataGrid.ItemsSource).Count == 0)
            UpdatesStackPanel.Visibility = Visibility.Collapsed;
              else
            UpdatesStackPanel.Visibility = Visibility.Visible;
        }
 public static void SetForeground(System.Windows.DependencyObject element, System.Windows.Media.Brush value)
 {
 }
Пример #33
0
 private void ChangeColor(Brush brush)
 {
     Username.Background = brush;
     Chips.Background    = brush;
     Bet.Background      = brush;
 }
Пример #34
0
 //holy shit
 public void UpdateBackgroundColor(System.Drawing.Color c)
 {
     System.Windows.Media.BrushConverter bc = new System.Windows.Media.BrushConverter();
     System.Windows.Media.Brush          b  = (System.Windows.Media.Brush)bc.ConvertFrom(System.Drawing.ColorTranslator.ToHtml(c));
     listPeers.Background = b;
 }
Пример #35
0
        public Main()
        {
            Initialized += MainInitialized;
            InitializeComponent();
            frame1.NavigationService.LoadCompleted += delegate(object sender, NavigationEventArgs args)
                                                      { this.frame1.NavigationService.RemoveBackEntry(); };
            //Set title with version info.
            Version version = Assembly.GetExecutingAssembly().GetName().Version;
            Title = "Octgn  version " + version;

            frame1.Navigate(new ContactList());
            DebugWindowCommand.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Control));

            var cb = new CommandBinding(DebugWindowCommand,
                                        MyCommandExecute, MyCommandCanExecute);
            CommandBindings.Add(cb);

            var kg = new KeyGesture(Key.M, ModifierKeys.Control);
            var ib = new InputBinding(DebugWindowCommand, kg);
            InputBindings.Add(ib);
            //Program.LobbyClient.OnFriendRequest += lobbyClient_OnFriendRequest;
            Program.LobbyClient.OnFriendRequest += LobbyClientOnOnFriendRequest;
            Program.LobbyClient.OnDataRecieved += LobbyClientOnOnDataRecieved;
            Program.LobbyClient.OnDisconnect += LobbyClientOnOnDisconnect;
            tbUsername.Text = Program.LobbyClient.Username;
            tbStatus.Text = Program.LobbyClient.CustomStatus;
            _originalBorderBrush = NotificationTab.Background;
            var cm = new ContextMenu();
            cm.MenuItems.Add("Show", CmShowClick).DefaultItem = true;
            cm.MenuItems.Add("Log Off", CmLogOffClick);
            cm.MenuItems.Add("-");
            cm.MenuItems.Add("Quit", CmQuitClick);
            SystemTrayIcon = new NotifyIcon
                                 {
                                     Icon = Properties.Resources.Icon,
                                     Visible = false,
                                     ContextMenu = cm,
                                     Text = Properties.Resources.Main_Main_Octgn
                                 };
            SystemTrayIcon.DoubleClick += SystemTrayIconDoubleClick;
            // Insert code required on object creation below this point.
            RefreshGameFilter(true);
            tbUsername.Cursor = Cursors.Arrow;
            tbUsername.ForceCursor = true;
            tbStatus.Cursor = Cursors.Pen;
            tbStatus.ForceCursor = true;
        }
Пример #36
0
 private void ButtonStart_Click(object sender, RoutedEventArgs e)
 {
     StartButtonColor       = ButtonStart.Background;
     ButtonStart.Background = System.Windows.Media.Brushes.Green;
     Automate();
 }