/// <summary> /// 切换鼠标指针为默认状态 /// </summary> private void MainWindow_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Cursor = ((TextBlock)CursorDictionary["CursorPointer"]).Cursor; var dictionary = new Dictionary <string, string> { { "Width", ActualWidth.ToString(CultureInfo.InvariantCulture) }, { "Height", ActualHeight.ToString(CultureInfo.InvariantCulture) } }; IniFileIo.IniFileWrite("DedicatedServerConfigure", "Window", dictionary); }
private void UpdateHtml() { if (!(ActualWidth > 0)) { return; } var fontColor = ColorUtility.ToHex((Color)Resources["PhoneForegroundColor"]); var backgroundColor = ColorUtility.ToHex((Color)Resources["PhoneBackgroundColor"]); //var script = "<script>function getDocHeight() { " + // "return document.getElementById('pageWrapper').offsetHeight; }" + // "function SendDataToPhoneApp() {" + // "window.external.Notify('' + getDocHeight());" + // "}</script>"; //var script = "<script>window.external.Notify('loaded');</script>"; var html = "<html>" + "<head>" + "<style>" + "body { font-family: " + Resources["PhoneFontFamilyNormal"] + ";width:" + ActualWidth.ToString() + "px;" + "margin:0px; padding: 0px; background-color:" + backgroundColor + "; " + "font-size: 17pt }\n" + "a { color:" + fontColor + "; }\n" + "ul { margin:0; padding-left:40px; }\n" + "p { padding:0; margin-left:0px; margin-top:0px; margin-right:0px; margin-bottom:12px; }\n" + "h1 { font-family: " + Resources["PhoneFontFamilySemiLight"] + "; " + "font-size: 54pt; " + "padding:0; margin-left:0px; margin-top:12px; margin-right:0px; margin-bottom:12px;}\n" + "h2 { font-family: " + Resources["PhoneFontFamilySemiLight"] + "; " + "font-size: 24pt; " + "padding:0; margin-left:0px; margin-top:12px; margin-right:0px; margin-bottom:12px;}\n" + "small { font-family: " + Resources["PhoneFontFamilyNormal"] + "; " + "font-size: 15pt; }\n" + Css + "\n" + "</style>" + "<meta name=\"viewport\" content=\"initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0\" />" + "<meta name=\"viewport\" content=\"user-scalable=no\" />" + "<meta name=\"viewport\" content=\"width=" + ActualWidth + "\" />" + "</head>" + "<body onLoad=\"SendDataToPhoneApp()\">" + "<div id=\"pageWrapper\" style=\"width: 100%; color:" + fontColor + ";\" >" + Html.Replace("%width%", ActualWidth.ToString()) + "</div></body></html>"; browser.IsScriptEnabled = true; //browser.ScriptNotify += OnScriptNotify; browser.NavigateToString(html); }
private void ResizeWindow(ResizeDirection direction) { SendMessage(_hwndSource.Handle, WmSyscommand, (IntPtr)(61440 + direction), IntPtr.Zero); var systemWorkAreaRect = SystemParameters.WorkArea; if (Width == systemWorkAreaRect.Width && Height == systemWorkAreaRect.Height) { UiBtnMaximized.Visibility = Visibility.Collapsed; UiBtnNormal.Visibility = Visibility.Visible; } else { UiBtnMaximized.Visibility = Visibility.Visible; UiBtnNormal.Visibility = Visibility.Collapsed; } var dictionary = new Dictionary <string, string> { { "Width", ActualWidth.ToString(CultureInfo.InvariantCulture) }, { "Height", ActualHeight.ToString(CultureInfo.InvariantCulture) } }; IniFileIo.IniFileWrite("DedicatedServerConfigure", "Window", dictionary); }
private void OnLayoutUpdated(object sender, EventArgs eventArgs) { TextBox.Text = ActualWidth.ToString(CultureInfo.InvariantCulture); }
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 }
private void MainWindow_LayoutUpdated(object sender, EventArgs e) { textBox.Text = ActualWidth.ToString(); }
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")); }
private void Window_SizeChanged(object sender, SizeChangedEventArgs e) { SetSizeControls(); Title = ActualWidth.ToString(); }
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; }