コード例 #1
0
ファイル: AppPage.cs プロジェクト: hyptechdev/SubSonic8
        /// <summary>
        /// Initializes a new instance of the <see cref="AppPage"/> class.
        /// </summary>
        public AppPage()
        {
            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                return;
            }

            // When this page is part of the visual tree make two changes:
            // 1) Map application view state to visual state for the page
            // 2) Handle keyboard and mouse navigation requests
            Loaded += (sender, e) =>
            {
                StartLayoutUpdates(sender, e);

                // Keyboard and mouse navigation only apply when occupying the entire window
                if (ActualHeight.Equals(Window.Current.Bounds.Height) &&
                    ActualWidth.Equals(Window.Current.Bounds.Width))
                {
                    // Listen to the window directly so focus isn't required
                    Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated +=
                        CoreDispatcher_AcceleratorKeyActivated;
                    Window.Current.CoreWindow.PointerPressed +=
                        CoreWindow_PointerPressed;
                }
            };

            // Undo the same changes when the page is no longer visible
            Unloaded += (sender, e) =>
            {
                StopLayoutUpdates(sender, e);
                Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= CoreDispatcher_AcceleratorKeyActivated;
                Window.Current.CoreWindow.PointerPressed -= CoreWindow_PointerPressed;
            };
        }
コード例 #2
0
 public void ZoomToFullEnvelope()
 {
     if (Map.Envelope == null)
     {
         return;
     }
     if (ActualWidth.IsNanOrZero())
     {
         return;
     }
     viewport.Resolution = Map.Envelope.Width / ActualWidth;
     viewport.Center     = Map.Envelope.GetCentroid();
 }
コード例 #3
0
ファイル: MapControl.cs プロジェクト: vkctata/Mapsui
        public void ZoomToFullEnvelope()
        {
            if (Map.Envelope == null)
            {
                return;
            }
            if (ActualWidth.IsNanOrZero())
            {
                return;
            }
            Map.Viewport.Resolution = Map.Envelope.Width / ActualWidth;
            Map.Viewport.Center     = Map.Envelope.Centroid;

            OnViewChanged();
        }
コード例 #4
0
        private SKPoint GetCardLocation(IndividualPileWPF thisControl) // harder
        {
            var thisIndex = _thisStack !.Children.IndexOf(thisControl);

            if (thisIndex == -1)
            {
                throw new BasicBlankException("It should have found the card location for the individual control for animations");
            }
            int maxColumns;

            maxColumns       = _thisCanvas !.ActualWidth.RoundToLowerNumber();
            var(row, column) = GetRowColumn(thisIndex, maxColumns);
            var thisHeight = _thisStack.ItemHeight * row;
            var thisWidth  = _thisStack.ItemWidth * column;

            return(new SKPoint((float)thisWidth, (float)thisHeight));
        }
コード例 #5
0
 UpdateLayout(new Size(ActualWidth, ActualHeight));
コード例 #6
0
        void OnWidthChanged(double newWidth)
        {
            //где newWidth - ширина колонки дня

            if (newWidth <= 0d)
            {
                return;
            }

            Leasing b = Business;

            if (b == null)
            {
                return;
            }

            #region расчёт отступа слева

            var offsetLeft = 0d;
            var startDay   = b.DateStart.Day;

            //если начало в текущем месяце
            if (b.MonthCount == 1 || b.DateStart.Month == b.CurrentMonth.Index)
            {
                if (startDay > 1)
                {
                    //т.к. дня нумеруются с единицы, то для первого дня отступ будет 0 дней, для второго - 1 и т.д.
                    var dayOffsetCount = startDay - 1;
                    offsetLeft = dayOffsetCount * (newWidth) + (dayOffsetCount * 1); //1 - ширина границ у колонок
                }
            }
            //для продолжения / сквозного месяца смещения нет

            //изменяем отступ элемента от левого края
            if (offsetLeft > 0)
            {
                if (offsetLeft != Margin.Left)
                {
                    Margin = new Thickness(offsetLeft, Margin.Top, Margin.Right, Margin.Bottom);
                }
            }

            #endregion

            #region  асчёт ширины TextBlock'a

            var width = 0d;

            var dayCount = 1; //прибавляем единичку, так как при сложении/вычитании теряем день

            //если машину взяли/вернули в течении 1 месяца
            if (b.MonthCount == 1)
            {
                dayCount += (b.DateEnd - b.DateStart).Days;
            }

            //если машина занята несколько месяцев
            else
            {
                var currentMonth = b.CurrentMonth.Index;

                //для месяца, в котором начали съём
                if (b.DateStart.Month == currentMonth)
                {
                    //отсчитываем от конца начального месяца
                    dayCount += (b.CurrentMonth.DayCount - b.DateStart.Day);
                }

                //для месяца в котором закончили съём
                else if (b.DateEnd.Month == currentMonth)
                {
                    dayCount = b.DateEnd.Day; //индекс дня - количество дней от начала месяца
                }
                //если период начинается и заканчивается за пределами текущего месяца
                else
                {
                    //берём первую дату месяца
                    var curentDate = b.CurrentMonth[1];
                    //если 'начало' < 'текущая дата' < 'конец'
                    dayCount = ((b.DateStart < curentDate) && (curentDate < b.DateEnd))
                        ? b.CurrentMonth.DayCount //берём количество дней в текущем месяце (закрашиваем всё)
                        : 0;                      //0 - хз чего ещё делать. В этом месяце занятости не было, хз как сюда попало
                }
            }

            if (dayCount < 0)
            {
                m_loger.Log("Получен отрицательный период аренды. Значение сброшено в 0", MessageType.Debug
                            , new LogParameter("Съёмщик", b.Title)
                            , new LogParameter("Комментарий", b.Comment)
                            , new LogParameter("Дата начала", b.DateStart.ToShortDateString())
                            , new LogParameter("Дата окончания", b.DateEnd.ToShortDateString()));

                dayCount = 0;
            }

            width = (newWidth * dayCount) + dayCount; //прибавляем количество дней, т.к. ширина границ - 1

            Width   = width;
            b.Width = width.ToString() + " | " + ActualWidth.ToString();

            #endregion
        }
コード例 #7
0
 private void MainWindow_LayoutUpdated(object sender, EventArgs e)
 {
     textBox.Text = ActualWidth.ToString();
 }
コード例 #8
0
        private void SaveConfig()
        {
            var isMaximized = WindowState == WindowState.Maximized;

            ConfigSevice.SetConfig(ConfigKey.WindowMaximized, isMaximized ? "1":"0");
            if (!isMaximized)
            {
                ConfigSevice.SetConfig(ConfigKey.WindowSize, string.Format("{0},{1}", ActualWidth.ToString("F"), ActualHeight.ToString("F")));
            }
            ConfigSevice.SetConfig(ConfigKey.WindowOpacity, Opacity.ToString("F"));
            ConfigSevice.SetConfig(ConfigKey.Background, (BdBackground.Background as SolidColorBrush).Color.ToString());
            ConfigSevice.SetConfig(ConfigKey.FontSize, sFontSize.Value.ToString("F"));
            ConfigSevice.SetConfig(ConfigKey.FontBrightness, sBrightness.Value.ToString("F"));
        }
コード例 #9
0
 private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     SetSizeControls();
     Title = ActualWidth.ToString();
 }
コード例 #10
0
        public GameWindow(int size, int bombs)
        {
            InitializeComponent();


            Size             = size;          //need to change
            Amaount_of_bombs = bombs;         //need to change
            bombsCounter     = bombs;
            bombtbx.Text     = Amaount_of_bombs.ToString();
            bombtbx.FontSize = 20;
            TimeCounter      = 0;
            clocktbx.Text    = TimeCounter.ToString();; // initialize bomb counter

            int xPos = 0;                               // var to alocate the buttons in the grid
            int yPos = 0;                               // var to alocate the buttons in the grid

            Board = new MyButton[Size, Size];


            System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();    // create timer for the clock
            dispatcherTimer.Tick    += DispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();
            isClockRunable = false;
            Image  image = new Image();
            string path  = Environment.CurrentDirectory;
            string path2 = path.Substring(0, path.LastIndexOf("bin")) + @"Pictures\happy-face.png";

            image.Source        = new BitmapImage(new Uri(path2));
            startButton.Content = image;


            for (int i = 0; i < Size; i++)    // create the buttons grid
            {
                for (int j = 0; j < Size; j++)
                {
                    Board[i, j] = new MyButton(i, j, Size)
                    {
                        Width  = 33, // Width of button
                        Height = 26  // Height of button
                    };
                    Board[i, j].Click += OnButtonCliked;
                    Board[i, j].MouseRightButtonDown += OnButtonRightCliked;

                    // Location of button:
                    Canvas.SetLeft(Board[i, j], xPos);
                    Canvas.SetTop(Board[i, j], yPos);
                    // Add buttons to a Panel:
                    pnlButtons.Children.Add(Board[i, j]);

                    xPos = xPos + (int)Board[i, j].Width; // Left of next button
                }
                yPos += 26;
                xPos  = 0;
            }
            DisableAllButton();

            Random rnd = new Random();

            for (int i = 0; i < bombs; i++)      // locate random bomb's location
            {
                int x_cordinate = rnd.Next(0, Size);
                int y_cordinate = rnd.Next(0, size);
                if (Board[y_cordinate, x_cordinate].num == -1)
                {
                    i--;
                }
                else
                {
                    Board[y_cordinate, x_cordinate].num = -1;
                }
            }
            for (int i = 0; i < Size; i++)           // arenge the board and set each button with the corspone picure
            {
                for (int j = 0; j < Size; j++)
                {
                    if (Board[i, j].num != -1)
                    {
                        Board[i, j].num = getNumOfBombes(i, j);
                    }
                    switch (Board[i, j].num)
                    {
                    case -1:
                        path  = Environment.CurrentDirectory;
                        path2 = path.Substring(0, path.LastIndexOf("bin")) + @"\Pictures\bomb.jpg";
                        Board[i, j].Image.Source = new BitmapImage(new Uri(path2));     // set the picture behaind to bomb picture
                        break;

                    case 0:
                        path  = Environment.CurrentDirectory;
                        path2 = path.Substring(0, path.LastIndexOf("bin")) + @"\Pictures\empty.png";
                        Board[i, j].Image.Source = new BitmapImage(new Uri(path2));        // set the picture behaind to bomb picture
                        break;

                    case 1:
                        path  = Environment.CurrentDirectory + @"\Pictures\one.png";
                        path2 = path.Substring(0, path.LastIndexOf("bin")) + @"\Pictures\one.png";
                        Board[i, j].Image.Source = new BitmapImage(new Uri(path2));       // set the picture behaind to bomb picture
                        break;

                    case 2:
                        path  = Environment.CurrentDirectory;
                        path2 = path.Substring(0, path.LastIndexOf("bin")) + @"\Pictures\\two.png";
                        Board[i, j].Image.Source = new BitmapImage(new Uri(path2));        // set the picture behaind to bomb picture
                        break;

                    case 3:
                        path  = Environment.CurrentDirectory;     // set the picture behaind to bomb picture
                        path2 = path.Substring(0, path.LastIndexOf("bin")) + @"\Pictures\three.png";
                        Board[i, j].Image.Source = new BitmapImage(new Uri(path2));
                        break;

                    case 4:
                        path  = Environment.CurrentDirectory;
                        path2 = path.Substring(0, path.LastIndexOf("bin")) + @"\Pictures\for.png";
                        Board[i, j].Image.Source = new BitmapImage(new Uri(path2));       // set the picture behaind to bomb picture
                        break;

                    case 5:
                        path  = Environment.CurrentDirectory;
                        path2 = path.Substring(0, path.LastIndexOf("bin")) + @"\Pictures\five.png";
                        Board[i, j].Image.Source = new BitmapImage(new Uri(path2));       // set the picture behaind to bomb picture
                        break;

                    case 6:
                        path  = Environment.CurrentDirectory;
                        path2 = path.Substring(0, path.LastIndexOf("bin")) + @"\Pictures\six.png";
                        Board[i, j].Image.Source = new BitmapImage(new Uri(path2));      // set the picture behaind to bomb picture
                        break;

                    case 7:
                        path  = Environment.CurrentDirectory;
                        path2 = path.Substring(0, path.LastIndexOf("bin")) + @"\Pictures\seven.png";
                        Board[i, j].Image.Source = new BitmapImage(new Uri(path2));      // set the picture behaind to bomb picture
                        break;

                    case 8:
                        path  = Environment.CurrentDirectory;
                        path2 = path.Substring(0, path.LastIndexOf("bin")) + @"\Pictures\eghit.png";
                        Board[i, j].Image.Source = new BitmapImage(new Uri(path2));      // set the picture behaind to bomb picture
                        break;
                    }
                }
            }
            this.Height = Size * 26 + 190;
            this.Width  = Size * 34 + 32 / Size;
            string temp = this.ActualHeight.ToString() + ActualWidth.ToString();

            clocktbx.Text = temp;
        }