//[DllImport("Kernel32.dll")] //public static extern void GetSystemTime(ref SystemTime sysTime); //[DllImport("Kernel32.dll")] //public static extern void GetLocalTime(ref SystemTime sysTime); public static bool SetLocalTime(TimeControl uc) { bool flag = false; SystemTime sysTime = new SystemTime(); sysTime.wYear = Convert.ToUInt16(uc.Year); sysTime.wMonth = Convert.ToUInt16(uc.Month); sysTime.wDay = Convert.ToUInt16(uc.Day); sysTime.wHour = Convert.ToUInt16(uc.Hour); sysTime.wMinute = Convert.ToUInt16(uc.Minute); sysTime.wSecond = Convert.ToUInt16(0); //注意: //结构体的wDayOfWeek属性一般不用赋值,函数会自动计算,写了如果不对应反而会出错 //wMiliseconds属性默认值为一,可以赋值 try { flag = SetLocalTime(ref sysTime); } //由于不是C#本身的函数,很多异常无法捕获 //函数执行成功则返回true,函数执行失败返回false //经常不返回异常,不提示错误,但是函数返回false,给查找错误带来了一定的困难 catch { PopWindowsLib.PopOk POP = new PopWindowsLib.PopOk(); POP.ShowDialog("修改失败"); } return(flag); }
}//切换到全屏播放视图 private void ShowWindow() { PopWindowsLib.PopOk pop = new PopWindowsLib.PopOk(); pop.IsShowGrid = false; pop.Text = "扩展功能暂未提供"; pop.ShowDialog(); }//点击功能按钮的弹出窗口,该函数可去掉或修改
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.MainWindow = ((PopWindowsLib.PopOk)(target)); return; case 2: this.OverLay = ((System.Windows.Controls.Grid)(target)); return; case 3: this.rectangle = ((System.Windows.Shapes.Rectangle)(target)); return; case 4: this.line = ((System.Windows.Shapes.Line)(target)); return; case 5: this.CC_Main = ((System.Windows.Controls.ContentControl)(target)); return; case 6: this.TBK_Content = ((System.Windows.Controls.TextBlock)(target)); return; case 7: this.BTN_Ok = ((System.Windows.Controls.Button)(target)); return; } this._contentLoaded = true; }